How to Deploy a Hugo Site for Free
Hugo is one of the fastest static site generators. It builds most sites in seconds and needs no Node.js or package.json. This guide shows how to deploy a Hugo site for free on LaunchPad, with free SSL and automatic deploys from GitHub or GitLab.
What you need
- A Hugo site in a GitHub or GitLab repository.
- A free Hostmargin account.
- A build that works locally: running
hugowrites the site topublic.
Step 1: Set baseURL
Hugo uses baseURL to build links, so set it to your site's address:
# hugo.toml
baseURL = 'https://your-site.lplive.xyz/'
languageCode = 'en-in'
title = 'My site'
Using your own domain? Put that address here instead.
Step 2: Commit your theme as normal files
The build only sees files that are committed to the repository, and Git submodules aren't fetched. If you added the theme with git submodule add, turn it into normal files once:
git rm --cached themes/your-theme
rm -rf themes/your-theme/.git
git add themes/your-theme
git commit -m "Vendor the theme"
git push
If you downloaded the theme as a ZIP and copied it into themes/, just make sure that folder is committed.
Step 3: Create the project
- Sign in at launchpad.hostmargin.com and click New project.
- Choose GitHub or GitLab, paste the repository URL and pick the branch.
- Choose the Hugo preset:
| Setting | Value |
|---|---|
| Build command | hugo |
| Output directory | public |
LaunchPad builds with the official Hugo image, so no setup is needed. For smaller pages, change the build command to hugo --minify.
Step 4: Deploy
Pick a free subdomain and click Create & Deploy. Hugo builds are quick: most sites are live within a minute. Your site is on HTTPS from the first deploy.
Step 5: Deploy on every push
Add the webhook URL and secret from Settings to your repository. Write a post in Markdown, git push, and it's published.
Common problems
The site has no styles or broken links
baseURL doesn't match the address you're visiting. Update it in hugo.toml and push again.
"found no layout file" or a blank site
The theme isn't in the repository, often because it's a Git submodule. Commit it as normal files (see Step 2), and check that theme in your config names the folder correctly.
Drafts don't show
Hugo skips pages with draft: true unless you build with --buildDrafts. Set draft: false on pages you want published.
Next steps
- See the Hugo section of the docs.
- Schedule a post to go live later with Scheduled publishing in Site controls.
- Add your own domain from the Domains page.