HUGO
News Docs Themes Community GitHub

Custom 404 page

Create a template to render a 404 error page.

To render a 404 error page in the root of your site, create a 404 template in the root of the layouts directory. For example:

layouts/404.html
{{ define "main" }}
  <h1>404 Not Found</h1>
  <p>The page you requested cannot be found.</p>
  <p>
    <a href="{{ .Site.Home.RelPermalink }}">
      Return to the home page
    </a>
  </p>
{{ end }}

For multilingual sites, add the language key to the file name:

layouts/
├── 404.de.html
├── 404.en.html
└── 404.fr.html

Your production server redirects the browser to the 404 page when a page is not found. Capabilities and configuration vary by host.

HostCapabilities and configuration
Amazon CloudFrontSee details.
Amazon S3See details.
ApacheSee details.
Azure Static Web AppsSee details.
Azure StorageSee details.
CaddySee details.
Cloudflare PagesSee details.
DigitalOcean App PlatformSee details.
FirebaseSee details.
GitHub PagesRedirection to is automatic and not configurable.
GitLab PagesSee details.
NGINXSee details.
NetlifySee details.