How to Host Your Website
Because your website is static, it can be hosted virtually anywhere using any web server.
However, we highly suggest you to deploy your website using Netlify.
Netlify can host your website for free, it’s very easy to use since it’s linked to your GitHub profile, and it provides some great perks, like a global CDN, free SSL certificates and continuous deployment.
The Last Piece of the Puzzle
-
First, if you haven’t done it already, create a new GitHub repository for your website. If you don’t know how, you can read about it here.
-
Add and commit a new file to your repo, called
netlify.toml
. This file is a sort of recipe for Netlify on how to build your website. Inside the file, write the following:
[build]
command = "hugo --gc --minify -b $URL"
publish = "public"
[build.environment]
HUGO_VERSION = "0.81.0"
HUGO_ENABLEGITINFO = "true"
[context.production.environment]
HUGO_ENV = "production"
[context.deploy-preview]
command = "hugo --gc --minify --buildFuture -b $DEPLOY_PRIME_URL"
[context.branch-deploy]
command = "hugo --gc --minify -b $DEPLOY_PRIME_URL"
-
Create a new Netlify account. Go to app.netlify.com and sign up using GitHub. Select “Authorize application” when prompted.
-
Now create a “New site from Git”.
-
Follow the required steps. You will need to select and authorize GitHub again (this time with added permissions to your repos).
-
Select your new website repository. You can then change a few setup options.
- Keep publishing from the
master
branch - The build command is:
hugo
(or the specified command in thenetlify.toml
) - The default publish directory is
public
- Keep publishing from the
-
Deploy!
- Once it’s done, you should see a successful message and an URL for your website (which has been automatically generated for you). You can change the URL in “Settings”. You can now visit your live website!
You’ve made it!
You created a website with continuous deployment. What does that mean?
It means that Netlify is now actively “watching” your GitHub repository.
Every time you commit to your repository, the website will be automatically rebuilt and redeployed! You no longer need to deal with Netlify. From now on, you can edit your website locally, and when you’re happy about the edits, you can simply commit. Pretty neat, isn’t it?
See Also
- Learn how to add a custom domain to your Netlify-hosted website
- Learn how to set up HTTPS on custom domains
- Check out other hosting and deployment options
- Read a more detailed guide on how to host your Hugo website on Netlify
- Learn how to publish a set of Distill articles as a website