# Create a helpful 404 page

- Check 05.08 · HTTP and redirects · Critical
- Source: https://checklist-seo-geo.com/en/http-redirects/create-helpful-404-page
- Create a 404 page that returns a real 404 code and puts visitors back on track, on Apache, Nginx, AWS, WordPress, Shopify, Laravel, Next.js or your CMS.
- Updated on 2026-11-25
- Licence: CC BY 4.0. Credit “Checklist SEO & GEO” with a link to https://checklist-seo-geo.com/en/http-redirects/create-helpful-404-page.
- Plugin checklist-seo-geo: 1.3.1 · https://github.com/maximegaul/checklist-seo-geo

## In short

A helpful 404 page does two things at once: it responds with the `404 Not Found` HTTP code, so that search engines know the URL does not exist, and it helps visitors find what they were looking for, with a clear message, the site's navigation, a search box and links to the main pages. This check consists of creating this template, wiring it up correctly on the server or the CMS, and monitoring 404s to fix the most frequent ones.

## Why it matters

404s are unavoidable: a mistyped link on another site, an old URL shared on social media, a typo, a deleted page. AI assistants also sometimes send people to inaccurate or defunct addresses. The visitor who lands there did nothing wrong; a raw error page, with no menu or link, makes them leave the site.

For search engines, the code matters more than the content. Google treats all 4xx codes (except 429) as non-existent content and gradually removes those URLs from the index. It points out that a custom 404 page helps visitors, but that the server must always return the 404 code. If the “not found” page returns 200, Google reports it as a soft 404, keeps crawling it and may index it.

Two common practices should be avoided:

- **Redirecting all 404s to the homepage**: the visitor loses the context of their request, and Google may treat these redirects as soft 404s. See [avoid redirecting all removed pages to the homepage](https://checklist-seo-geo.com/en/http-redirects/avoid-redirecting-all-removed-pages-homepage).
- **Setting up the error page as a redirect** to `/404`: the requested URL then returns 302, and `/404` returns 200 or 404. The visitor loses the faulty URL from their address bar.

## What it improves

- **Retention**: some of the lost visitors head off to a useful page instead of leaving the site.
- **Clean indexing**: a real 404 code prevents soft 404s and non-existent URLs in the index.
- **Diagnosis**: monitoring 404s reveals broken links, old URLs that are still requested and wrong addresses cited elsewhere, including by AI assistants.
- **Brand image**: a polished page reassures visitors that the site is serious. An indirect effect.
- **Rankings**: no direct effect; 404s in themselves do not penalize the site.

## How to check

Request a URL that does not exist:

```bash
curl -s -o /dev/null -w "%{http_code} %{redirect_url}\n" https://www.example.com/cette-page-n-existe-pas-123
```

Compliant result: `404` (or `410` for a deliberate removal), with no redirect URL. A `200` indicates a soft 404, a `301` or `302` a redirect to remove.

Then open the same URL in a browser and check that:

- the requested URL stays in the address bar;
- the site's header, menu and footer are present;
- a message clearly says that the page does not exist, without jargon;
- a search box and links to the main sections are visible without scrolling;
- the page loads quickly and contains no script errors.

Also test a non-existent URL in each section (`/blog/…`, `/produits/…`, `/en/…`): some CMSs and frameworks behave differently depending on the content type. The Search Console [URL Inspection tool](https://search.google.com/search-console?action=inspect) confirms the code Google receives.

## How to implement

### Before you start

Recommended content, in this order:

1. **A simple heading and sentence**: “This page cannot be found. It may have been moved or deleted, or the address contains an error.”
2. **An internal search box**, pointing to your results page.
3. **Four to eight useful links**: main sections, most visited pages and, for a store, the flagship categories.
4. **A way to get in touch** or to report the broken link.
5. **The usual navigation**: the site's header and footer.

Technical rules:

- **404 code** on the requested URL, with no redirect. Use 410 for content removed on purpose if your platform allows it. See [return 404/410 for removed content with no equivalent](https://checklist-seo-geo.com/en/http-redirects/return-404-410-removed-content-no-equivalent).
- **No automatic redirect** after a few seconds (`meta refresh` or script): Google may treat it as a redirect, and therefore as a soft 404.
- **Lightweight, self-contained page**: it must display even if the database or an API is down. Avoid loading heavy dynamic blocks on it.
- **Language**: on a multilingual site, display the 404 in the language of the URL prefix (`/en/…`).
- **No need to add `noindex`**: a page that returns 404 is not indexed. Next.js adds it on its own, with no negative effect.

> **Tip:** track 404s in your analytics tool and look at where they come from. A non-existent URL frequently requested from the same site, campaign or AI assistant deserves a 301 redirect to the page that matches the intent.

Tracking in Google Analytics, on the 404 template only, after the Google tag has loaded:

```html
<script>
  gtag('event', 'page_not_found', {
    page_location: window.location.href,
    page_referrer: document.referrer
  });
</script>
```

Then register the `page_referrer` parameter as a custom dimension if you want to analyze it. With Matomo, the documentation suggests renaming the page title before `trackPageView`, so that the URL and the referrer can be found in `Behaviour > Page titles`:

```js
_paq.push(['setDocumentTitle', '404/URL = ' + encodeURIComponent(document.location.pathname + document.location.search) + ' /From = ' + encodeURIComponent(document.referrer)]);
```

### Apache

Versions: Apache 2.4.

In the virtual host or the `.htaccess` file:

```apache
ErrorDocument 404 /404.html
ErrorDocument 410 /410.html
```

The path must be local. With a full URL (`ErrorDocument 404 https://www.example.com/404.html`), Apache sends a redirect instead of the error page, and the 404 code is lost. With a CMS or a framework, the application produces the 404: only set `ErrorDocument` for static files.

### Nginx

Versions: Nginx 1.18 and later.

In the `server` block:

```nginx
error_page 404 /404.html;

location = /404.html {
    root /var/www/example/errors;
    internal;
}
```

Do not write `error_page 404 =200 /404.html;`: the `=200` syntax replaces the code with 200. For a PHP application behind `fastcgi_pass` to use this page rather than its own, add `fastcgi_intercept_errors on;`; otherwise, let the application handle its 404. Reload with `sudo nginx -t && sudo systemctl reload nginx`.

### LiteSpeed

Versions: LiteSpeed Web Server 6.x; OpenLiteSpeed 1.7 and 1.8.

LiteSpeed Web Server reads the `ErrorDocument` directive in `.htaccess`: the Apache block works as is. OpenLiteSpeed only reads rewrite rules from `.htaccess`: declare the page in the WebAdmin console, `Virtual Hosts > your host > General > Customized Error Pages`, then do a graceful restart (`Graceful Restart`).

### Caddy

Versions: Caddy 2.8 and later.

```txt
example.com {
    root * /var/www/example
    file_server

    handle_errors 404 {
        rewrite * /404.html
        file_server
    }
}
```

`handle_errors` keeps the original error code. Filtering by code (`handle_errors 404`) dates from Caddy 2.8; before that, write `handle_errors` with no argument, which applies to all errors. Reload with `sudo systemctl reload caddy`.

### IIS

Versions: IIS 10 (Windows Server 2016 to 2025), unchanged since IIS 7.

In `web.config`:

```xml
<configuration>
  <system.webServer>
    <httpErrors errorMode="Custom" existingResponse="Replace">
      <remove statusCode="404" />
      <error statusCode="404" path="/404.html" responseMode="ExecuteURL" />
    </httpErrors>
  </system.webServer>
</configuration>
```

`ExecuteURL` serves the page while keeping the 404 code; `Redirect` would send a redirect.

### Cloudflare

Versions: Cloudflare dashboard, all plans, November 2026.

Cloudflare passes on the 404 code and page produced by the origin as they are: set up the page on the server or in the CMS. Its custom error pages mainly concern errors it generates itself (firewall, unreachable origin). Check that no cache rule forces a long lifetime on 404 responses: a page created later at the same address would stay unfindable until the cache is purged.

### AWS

Versions: AWS console (S3, CloudFront, Amplify Hosting), November 2026.

- **S3 static website**: in the bucket properties, under static website hosting, enter `404.html` as the error document. S3 serves it with the 404 code.
- **CloudFront**: on the `Error pages` tab, create a custom error response for the 404 code, with the path `/404.html` and the response code `404`. With a private S3 bucket, S3 returns 403 for a missing object: add the same response for 403.
- **Single-page application**: the widespread practice of returning `/index.html` with a 200 code for all 403 and 404 errors turns every non-existent URL into a soft 404. Keep the 404 code and let the application display the message.
- **Amplify Hosting**: a rewrite rule from the source `/<*>` to `/404.html` with the “404 (Rewrite)” type.

### Plesk

Versions: Plesk Obsidian 18.0.

In `Websites & Domains > your domain > Hosting Settings`, tick custom error document support, then edit the `not_found.html` file in the `error_docs` folder with the File Manager. With a CMS, let the application produce the 404.

### cPanel

Versions: cPanel & WHM 110 and later, Jupiter theme.

In `Advanced > Error Pages`, choose the domain, then `404 (Not Found)`, and enter the page's HTML. cPanel saves it as `404.shtml` and adds the directive to `.htaccess`.

### Shared hosting

The `ErrorDocument` block from the Apache section works with most hosting providers. Create the `404.html` file at the site root with the recommended links. If you use a CMS, its 404 template is the one to polish.

### Vercel

Versions: Vercel, all plans, November 2026.

A `404.html` file at the root of the publish directory serves as the 404 page for a static site. With Next.js, Nuxt or Astro, use the framework's convention.

### Netlify

Versions: Netlify, all plans, November 2026.

A `404.html` file at the root of the publish directory is served automatically with the 404 code. For a 404 per language, in `_redirects`:

```txt
/en/*  /en/404.html  404
/*     /404.html     404
```

### WordPress

Versions: WordPress 6.4 to 7.1 (classic themes and block themes).

- **Classic theme**: the theme's `404.php` file. Edit it in a child theme so you do not lose your changes on update, and add `get_search_form()` and the recommended links.
- **Block theme**: `Appearance > Editor > Templates`, “Page: 404” template. Add the Search and Navigation blocks and a list of links.
- **Plugins to avoid**: those that redirect all 404s to the homepage. Prefer the Redirection plugin, which logs 404s and lets you create targeted redirects.

WordPress returns the 404 code on its own; check it after installing any caching or security plugin.

### Shopify

Versions: Shopify admin, all plans, November 2026.

Open `Online Store > Themes > Customize`, choose the 404 page template in the template selector, then add sections: text, featured collections, search bar. In the code, the template is `templates/404.json` (or `404.liquid` on older themes). Shopify returns the 404 code.

### PrestaShop

Versions: PrestaShop 1.7, 8 and 9 (Classic and Hummingbird themes).

The template is `templates/errors/404.tpl` in the theme. Customize it in a child theme; add the search module and links to the main categories. PrestaShop returns the 404 code.

### Wix

Versions: Wix Editor, Premium plans, November 2026.

In the editor, open `Pages & Menu > Add Menu Item > New Page`, choose the 404 error page and a template, then customize it and publish. Customization requires a Premium plan and is not available for some apps, such as Wix Stores.

### Squarespace

Versions: Squarespace 7.1, all plans, November 2026.

Create a page in the “Not linked” section of the Pages panel, then select it as the 404 page in the settings. Squarespace states that Google may report a custom 404 as indexable: check the code with curl and, if Search Console raises an alert, follow the recommendation in Squarespace's help.

### Webflow

Versions: Webflow, all site plans, November 2026.

In the Pages panel, in the utility pages section, edit the 404 page like any other page. Webflow serves it with the 404 code.

### Laravel

Versions: Laravel 10 to 13.

Create `resources/views/errors/404.blade.php`; Laravel displays it with the 404 code for any non-existent route or any `abort(404)`.

```blade
@extends('layouts.app')

@section('content')
    <h1>{{ __('This page cannot be found') }}</h1>
    <p>{{ __('It may have been moved or deleted, or the address contains an error.') }}</p>

    <form action="{{ route('search') }}" method="get">
        <input type="search" name="q" aria-label="{{ __('Search') }}">
        <button type="submit">{{ __('Search') }}</button>
    </form>

    <ul>
        <li><a href="{{ route('home') }}">{{ __('Home') }}</a></li>
        <li><a href="{{ route('blog') }}">{{ __('Blog') }}</a></li>
        <li><a href="{{ route('contact') }}">{{ __('Contact') }}</a></li>
    </ul>
@endsection
```

Adapt the route names. To start from the default views: `php artisan vendor:publish --tag=laravel-errors`.

### Symfony

Versions: Symfony 6.4, 7.4 and 8.x, with `symfony/twig-pack`.

Create `templates/bundles/TwigBundle/Exception/error404.html.twig`. Symfony uses it in production with the 404 code; preview it in development at `/_error/404`.

### Next.js

Versions: Next.js 15 and 16 (App Router and Pages Router).

The page is created by file convention, which differs depending on the router used.

#### App Router

Create `app/not-found.tsx`: it is displayed for any URL with no route and for any call to `notFound()`.

```tsx
import Link from 'next/link';

export const metadata = { title: 'Page not found' };

export default function NotFound() {
  return (
    <main>
      <h1>This page cannot be found</h1>
      <p>It may have been moved or deleted, or the address contains an error.</p>
      <form action="/recherche">
        <input type="search" name="q" aria-label="Search" />
        <button type="submit">Search</button>
      </form>
      <ul>
        <li><Link href="/">Home</Link></li>
        <li><Link href="/blog">Blog</Link></li>
        <li><Link href="/contact">Contact</Link></li>
      </ul>
    </main>
  );
}
```

Next.js returns 404 if `notFound()` is called before streaming starts; afterwards, the code stays 200 with a `noindex` tag. Check that the content exists at the start of the page, before any component wrapped in `Suspense`.

#### Pages Router

Create `pages/404.tsx`: Next.js generates it as a static page and serves it with the 404 code for any URL with no route. For content missing from a dynamic route, return `{ notFound: true }` from `getStaticProps` or `getServerSideProps`: the same page is displayed with the 404 code.

```tsx
import Link from 'next/link';

export default function Custom404() {
  return (
    <main>
      <h1>This page cannot be found</h1>
      <p>It may have been moved or deleted, or the address contains an error.</p>
      <ul>
        <li><Link href="/">Home</Link></li>
        <li><Link href="/blog">Blog</Link></li>
        <li><Link href="/contact">Contact</Link></li>
      </ul>
    </main>
  );
}
```

### Nuxt

Versions: Nuxt 3 and 4.

The `error.vue` file receives the error as a prop and replaces the whole page. Trigger the 404 in the page itself, on the server side, so that the code is actually returned.

#### Nuxt 4

Create `app/error.vue`, next to `app.vue`. In a page whose content cannot be found:

```ts
throw createError({ status: 404, statusText: 'Page not found' })
```

#### Nuxt 3

Create `error.vue` at the project root. In a page whose content cannot be found:

```ts
throw createError({ statusCode: 404, statusMessage: 'Page not found' })
```

Nuxt 3 is no longer maintained: plan the migration to Nuxt 4.

## Common mistakes

- **404 page returning a 200 code**: it is a soft 404, reported by Search Console. See [fix soft 404s](https://checklist-seo-geo.com/en/indexing-canonicalization/fix-soft-404s).
- **Redirecting to `/404` or to the homepage**: the original code is lost and the visitor no longer sees the address they requested.
- **Single-page application that returns 200 everywhere**: every non-existent URL becomes an empty, indexable page. See [check SPA HTTP status codes](https://checklist-seo-geo.com/en/javascript-html-rendering/check-spa-http-status-codes).
- **Error page with no navigation**: the visitor is left with only the “Back” button.
- **Heavy 404 page** that queries the database or APIs: it crashes precisely when the site is fragile.
- **Never looking at 404s**: the most requested URLs reveal broken links to fix and redirects to create. See [fix broken internal links](https://checklist-seo-geo.com/en/http-redirects/fix-broken-internal-links).

## Frequently asked questions

### Should a custom 404 page return the 404 code?

Yes, always. The page content is meant for the visitor, the HTTP code for search engines. A “not found” page that returns 200 is treated by Google as a soft 404: it keeps being crawled and may end up in the index. Check with curl that a non-existent URL does return 404, or 410 for content removed on purpose, with no redirect at all.

### Should I redirect 404 errors to the homepage?

No. Redirecting all 404s to the homepage makes visitors lose the context of their search, and Google may treat these redirects as soft 404s. Keep a real, helpful 404 page, with search and links, and create targeted 301 redirects only for old URLs that have a precise equivalent, using your monitoring of the most frequent 404s as a guide.

### What should I put on a 404 page?

A clear message saying that the page does not exist, with no technical jargon, the site's usual navigation, an internal search box, a few links to the main sections or products, and a way to get in touch. Keep the page lightweight, with no dependency on the database or APIs, and display it in the language of the requested section on a multilingual site.

### Do 404 errors hurt a site's SEO?

No, 404 errors are a normal part of how the web works: Google states that they do not penalize the rest of the site. They only become a problem when they affect pages that should exist, when internal links lead to them, or when URLs that receive backlinks or traffic return 404. In those cases, fix the link or create a redirect to the equivalent.

## Resources

- [Google Search Central: HTTP status codes and soft 404s](https://developers.google.com/crawling/docs/troubleshooting/http-status-codes?hl=en)
- [Google Search Central: Managing your crawl budget (soft 404s)](https://developers.google.com/crawling/docs/crawl-budget?hl=en)
- [Apache: ErrorDocument](https://httpd.apache.org/docs/2.4/mod/core.html#errordocument) and [Nginx: error_page](https://nginx.org/en/docs/http/ngx_http_core_module.html#error_page)
- [Next.js: not-found](https://nextjs.org/docs/app/api-reference/file-conventions/not-found) and [Laravel: Custom HTTP error pages](https://laravel.com/framework/docs/errors#custom-http-error-pages)
- [Symfony: How to customize error pages](https://symfony.com/doc/current/controller/error_pages.html)
- [Matomo: How to track 404 pages](https://matomo.org/faq/how-to/faq_60/)

Next steps: [return 404/410 for removed content with no equivalent](https://checklist-seo-geo.com/en/http-redirects/return-404-410-removed-content-no-equivalent) and [fix soft 404s](https://checklist-seo-geo.com/en/indexing-canonicalization/fix-soft-404s).
