[hugo, netlify, domain, dns, github]

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

  1. 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.

  2. 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:

  command = "hugo --gc --minify -b $URL"
  publish = "public"

  HUGO_VERSION = "0.81.0"

  HUGO_ENV = "production"

  command = "hugo --gc --minify --buildFuture -b $DEPLOY_PRIME_URL"

  command = "hugo --gc --minify -b $DEPLOY_PRIME_URL"
  1. Create a new Netlify account. Go to app.netlify.com and sign up using GitHub. Select “Authorize application” when prompted.

  2. Now create a “New site from Git”.

New site from Git

  1. Follow the required steps. You will need to select and authorize GitHub again (this time with added permissions to your repos).

  2. 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 the netlify.toml)
    • The default publish directory is public
  3. Deploy!

Deploy with Netlify

  1. 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!

Netlify successful message


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

Contributed by Andrea Antonacci