Step 3 of 4 · 5 minutes, plus DNS time for a custom domain

Turn on GitHub Pages

Tell GitHub to serve your site, find its address, and optionally point your own domain at it.

GitHub Pages is GitHub’s free web hosting. It serves the finished site; the deployment action in the next guide builds it and hands it over.

Switch it on

  1. Open your repo on GitHub and click Settings.
  2. In the sidebar, under Code and automation, click Pages.
  3. Under Build and deployment, set Source to GitHub Actions.

That’s the only required setting. GitHub may offer a ready-made Hugo workflow at this point. You can skip it: the next guide gives you one that pins the same Hugo version you installed, so the site builds the same way on GitHub as on your computer.

Your site’s address

Repo nameSite address
janedoe.github.iohttps://janedoe.github.io/
anything else, e.g. mybloghttps://janedoe.github.io/myblog/

Put that address in hugo.toml as the baseURL:

baseURL = 'https://janedoe.github.io/myblog/'

The deployment action sets the address automatically when it builds, but keeping baseURL correct means feeds and links are right everywhere else too.

Use your own domain (optional)

If you own a domain, GitHub Pages can serve the site there, with a free HTTPS certificate.

  1. Verify the domain first, so nobody else can attach it to their Pages site. Click your profile picture, then Settings → Pages → Add a domain, and add the TXT record GitHub shows you at your domain registrar.

  2. Add DNS records at your registrar. For www.example.com, add a CNAME record for www pointing to janedoe.github.io. For the bare example.com, add these:

    TypeNameValue
    A@185.199.108.153
    A@185.199.109.153
    A@185.199.110.153
    A@185.199.111.153
    AAAA@2606:50c0:8000::153
    AAAA@2606:50c0:8001::153
    AAAA@2606:50c0:8002::153
    AAAA@2606:50c0:8003::153

    Set up both and GitHub redirects one to the other.

  3. Tell GitHub. In the repo’s Settings → Pages, type the domain under Custom domain and click Save. GitHub checks the DNS; this can take from a few minutes to a day while the records spread.

  4. Turn on HTTPS. Once the check passes, tick Enforce HTTPS. The certificate can take a little while to issue; the checkbox stays grey until it’s ready.

  5. Update baseURL in hugo.toml to the new address, such as https://www.example.com/.

Because the site deploys with an action, you don’t need a CNAME file in the repo. The setting in step 3 is what counts.