Missing Page Handling

If you would like to customize the content of the HTML 404 page, you can create a /content/404.md file with your content.

If you customize your 404 page, you should keep it out of the sitemap.xml by setting the hidden front matter parameter to true. To avoid having a /404/ web page generated you can set the Hugo rendering to never. The following is the front matter for the default 404 page with the theme which accomplishes all of this:

title: Page Not Found
hidden: true
# Prevent indexing by reputable search engines
noIndex: true
# Prevent the page from being rendered
_build:
  render: never

When you are running your site on the internet, it is important for SEO that you do not have soft 404 errors whereby missing pages return HTTP 200 status responses.

Deploying in Practice

Both Cloudflare pages and Netlify will use a 404.html page in the root of your static site for handling missing pages.

If you are using GitHub Pages, you can configure missing page handling by following their 404 page documentation.

Previewing 404 Pages on Older Hugo Versions

While you are developing locally in versions of Hugo prior to v0.103.0, hugo server will not automatically load your custom 404 page. You can test the appearance of your custom “not found” page by navigating your browser to /404.html.