How to create a custom 404 page in WordPress
In a block theme, create a custom 404 page under Appearance → Editor → Templates by editing or adding the Page: 404 template. In a classic theme, add a 404.php file to your child theme. WordPress sends the 404 status code itself, so your only job is the content.
A good 404 page admits the page is missing and gets the visitor somewhere useful in one click. It needs a plain message, a search box, and links to the few places most people want.
Step by step
1. Check which kind of theme you have
Look under Appearance. If you see Editor, the theme is a block theme and templates are edited in the Site Editor. If you see Customize and Theme File Editor instead, it is a classic theme and templates are PHP files.
2. Block theme: edit the 404 template
- Go to Appearance → Editor → Templates.
- Open Page: 404. WordPress describes it as the template that "displays when a visitor views a non-existent page, such as a dead link or a mistyped URL". If the theme does not ship one, add a new template and choose that type.
- Keep the header and footer template parts. In between, add a Heading, a Paragraph, a Search block and a short list of links.
- Click Save.
Changes apply to every missing URL at once. No page is created in Pages, and there is nothing to publish.
3. Classic theme: add 404.php
Copy 404.php from the parent theme into your child theme and edit it. If the parent has none, create it:
<?php get_header(); ?>
<main id="primary" class="site-main">
<h1>We can't find that page</h1>
<p>The link may be old or mistyped. Try a search, or start from one of these.</p>
<?php get_search_form(); ?>
<ul>
<li><a href="<?php echo esc_url( home_url( '/' ) ); ?>">Homepage</a></li>
<li><a href="<?php echo esc_url( home_url( '/blog/' ) ); ?>">Latest articles</a></li>
<li><a href="<?php echo esc_url( home_url( '/contact/' ) ); ?>">Contact us</a></li>
</ul>
</main>
<?php get_footer(); ?>
WordPress picks this file automatically for any request it cannot match. Without it, the theme's index.php is used.
4. Write content that helps
- Say what happened in a sentence, in your normal voice.
- Offer search. It is the fastest route for someone who knows what they wanted.
- Link to three to six destinations: the homepage, main categories or products, and contact.
- Skip heavy elements. Bots hit this page constantly. A slider or a large query for "related posts" on every missing URL is wasted load.
5. Set the title and description
With Hydrogen SEO, the 404 page's <title> and meta description are set under Hydrogen SEO → Titles & Meta → Special Pages. The defaults are Page Not Found %separator% %site_name% and "The page you are looking for could not be found." The plugin also prints noindex, follow on every 404 response as a built-in rule.
6. Verify the status code
The page must answer with status 404, not 200. Request an address that does not exist:
curl -sI https://example.com/this-page-does-not-exist/ | head -1
You should see 404. If you see 200, something is serving the error page as a normal page, usually a plugin or server rule that redirects all 404s to a regular page. If you see 301 or 302, missing URLs are being redirected somewhere, which Google tends to report as soft 404s.
7. Find out which URLs land there
Switch on the 404 Monitor under Hydrogen SEO → 404 Monitor. It records each missing URL with a hit count, the last referrer and the last user agent, and lets you turn a row into a redirect. That shows whether your 404 page is seen because of one broken menu link or a renamed post with links pointing at it.
Do not redirect 404s to the homepage
Sending every missing URL to the homepage looks tidy and helps nobody. Visitors lose the signal that the link was wrong and have to work out where they are. Google documents that redirecting to an irrelevant page may be treated as a soft 404, so the URLs linger in reports instead of dropping out. Redirect a missing URL only when a specific page replaces it.
Do not build it as a regular page
Creating a page called "404" under Pages and pointing errors at it by redirect produces a URL like /404/ that returns status 200. That is an indexable page saying "not found", plus a redirect on every broken link. Use the template. It keeps the requested URL in the address bar, where the visitor can spot a typo, and the correct status code.
Common questions
Where is the 404 page in WordPress?
It is a theme template, not a page. In block themes it is "Page: 404" in the Site Editor. In classic themes it is the 404.php file in the theme folder.
Should a 404 page be noindex?
A response with a 404 status is not indexed whatever tags it carries. Hydrogen SEO still prints noindex, follow on it, which does no harm and covers misconfigured servers.
Can I use a page builder for the 404 page?
Many builders offer a 404 template through their theme builder feature. After setting one up, run the curl check to confirm the response is still a 404.