Skip to main content
GitHub Pages supports custom domains, allowing you to serve your site from benson.vc instead of the default username.github.io URL.

How it works

The custom domain setup involves two key components:
  1. CNAME file: Tells GitHub Pages which custom domain to use
  2. DNS configuration: Points your domain to GitHub’s servers

CNAME file

The repository includes a CNAME file in the static/ directory:
static/CNAME
This file contains a single line with your domain:
benson.vc
The CNAME file must be in the static/ directory, not the root. Hugo copies files from static/ to public/ during the build, ensuring the CNAME file is included in the deployment.

How Hugo handles the CNAME file

During the build process:
1

Hugo builds the site

The hugo --minify command generates static files in public/.
2

Static files are copied

All files from static/ are copied to public/, including the CNAME file.
3

GitHub Actions deploys

The workflow pushes public/ contents (including CNAME) to the gh-pages branch.
4

GitHub Pages reads CNAME

GitHub Pages detects the CNAME file and configures the custom domain automatically.

DNS configuration

To point your domain to GitHub Pages, configure your DNS records:

For apex domain (benson.vc)

Create A records pointing to GitHub’s IP addresses:
185.199.108.153
185.199.109.153
185.199.110.153
185.199.111.153

For www subdomain

Create a CNAME record pointing to your GitHub Pages URL:
www.benson.vc → username.github.io
DNS changes can take up to 24 hours to propagate, though they usually happen within a few hours.

Verifying your custom domain

After configuring DNS, verify your setup:
1

Check GitHub Pages settings

Go to your repository’s SettingsPages. You should see “Custom domain: benson.vc” with a checkmark.
2

Verify DNS propagation

Use a DNS lookup tool to confirm your records are resolving correctly:
dig benson.vc +short
3

Test the domain

Visit https://benson.vc in your browser to ensure the site loads correctly.

Enabling HTTPS

GitHub Pages provides free HTTPS for custom domains:
1

Wait for DNS verification

GitHub Pages must verify your DNS configuration before enabling HTTPS.
2

Enable HTTPS

In SettingsPages, check the box for Enforce HTTPS.
3

Wait for certificate

GitHub Pages will automatically provision an SSL certificate. This can take a few minutes.

baseURL configuration

Ensure your Hugo configuration uses the custom domain:
baseURL = "https://benson.vc/"
This setting in config/_default/config.toml ensures all internal links and canonical URLs use your custom domain.

Troubleshooting

Domain not working

  • Verify the CNAME file exists in static/CNAME and contains only benson.vc
  • Check that DNS records are configured correctly
  • Ensure GitHub Pages is enabled and set to deploy from the gh-pages branch

HTTPS not available

  • Wait for DNS propagation (can take up to 24 hours)
  • Verify that GitHub Pages has verified your domain
  • Try removing and re-adding the custom domain in repository settings

Old content showing

  • Clear your browser cache
  • Check that the latest deployment succeeded in the Actions tab
  • Verify that baseURL in your Hugo config matches your custom domain

Maintaining the custom domain

Never delete the static/CNAME file. If it’s removed from the gh-pages branch, GitHub Pages will stop serving your site from the custom domain.
The CNAME file is automatically included in every deployment because:
  1. It’s stored in static/CNAME in your source code
  2. Hugo copies it to public/CNAME during build
  3. GitHub Actions deploys public/ to the gh-pages branch
As long as the file remains in static/, your custom domain will continue working.

Build docs developers (and LLMs) love