Fix 404 Error When Pushing Hugo to a Github Repository that Points to a Custom Domain

The Problem

You once experienced the joy of seeing your Hugo site up on github pages pointing to a custom url. Then you decided to push new pages to the repo and your custom domain is a 404 page! What’s happening??

The Solution

When you update your repository’s Github Pages settings to point to a custom domain, Github creates a file CNAME inside your directory /docs. You may have accidentally overwrote this file when you did your last git push! To solve this:

  1. Create the file CNAME inside a /static folder (which can be created in root and/or in your THEME folder)
  2. Add your domain inside that file in the format “”. Don’t add “https://” before it!.
  3. Wait a few minutes and then notice that your site is (hopefully) working again! If it’s not, consider reading our guide Loading Hugo into Github Pages.