Debian Codegraph @

docs/content/en/templates/404.md

raw
1 ---
2 title: Custom 404 page
3 linkTitle: 404 templates
4 description: Create a template to render a 404 error page.
5 categories: []
6 keywords: []
7 weight: 200
8 ---
9
10 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:
11
12 ```go-html-template {file="layouts/404.html"}
13 {{ define "main" }}
14 <h1>404 Not Found</h1>
15 <p>The page you requested cannot be found.</p>
16 <p>
17 <a href="{{ .Site.Home.RelPermalink }}">
18 Return to the home page
19 </a>
20 </p>
21 {{ end }}
22 ```
23
24 For multilingual projects, add the language key to the file name:
25
26 ```tree
27 layouts/
28 ├── 404.de.html
29 ├── 404.en.html
30 └── 404.fr.html
31 ```
32
33 Your production server redirects the browser to the 404 page when a page is not found. Capabilities and configuration vary by host.
34
35 Host|Capabilities and configuration
36 :--|:--
37 Amazon CloudFront|See [details](https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/GeneratingCustomErrorResponses.html).
38 Amazon S3|See [details](https://docs.aws.amazon.com/AmazonS3/latest/userguide/CustomErrorDocSupport.html).
39 Apache|See [details](https://httpd.apache.org/docs/2.4/custom-error.html).
40 Azure Static Web Apps|See [details](https://learn.microsoft.com/en-us/azure/static-web-apps/configuration#response-overrides).
41 Azure Storage|See [details](https://learn.microsoft.com/en-us/azure/storage/blobs/storage-blob-static-website#setting-up-a-static-website).
42 Caddy|See [details](https://caddyserver.com/docs/caddyfile/directives/handle_errors).
43 Codeberg Pages|See [details](https://docs.codeberg.org/codeberg-pages/advanced-usage/#custom-error-page-for-404s).
44 Cloudflare Pages|See [details](https://developers.cloudflare.com/pages/configuration/serving-pages/#not-found-behavior).
45 DigitalOcean App Platform|See [details](https://docs.digitalocean.com/products/app-platform/how-to/manage-static-sites/#configure-a-static-site).
46 Firebase|See [details](https://firebase.google.com/docs/hosting/full-config#404).
47 GitHub Pages|Redirection to is automatic and not configurable.
48 GitLab Pages|See [details](https://docs.gitlab.com/ee/user/project/pages/introduction.html#custom-error-codes-pages).
49 NGINX|See [details](https://nginx.org/en/docs/http/ngx_http_core_module.html#error_page).
50 Netlify|See [details](https://docs.netlify.com/routing/redirects/redirect-options/).