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.htmlYour production server redirects the browser to the 404 page when a page is not found. Capabilities and configuration vary by host.
| Host | Capabilities and configuration | 
|---|---|
| Amazon CloudFront | See details. | 
| Amazon S3 | See details. | 
| Apache | See details. | 
| Azure Static Web Apps | See details. | 
| Azure Storage | See details. | 
| Caddy | See details. | 
| Cloudflare Pages | See details. | 
| DigitalOcean App Platform | See details. | 
| Firebase | See details. | 
| GitHub Pages | Redirection to is automatic and not configurable. | 
| GitLab Pages | See details. | 
| NGINX | See details. | 
| Netlify | See details. | 
Last updated:
March 6, 2025
:
content: Replace calls to the code shortcode with fenced code blocks (fd628be6e)
Improve this page
