SEO – Custom 404 Page

A 404 error means that the page does not exist. This happens when a link is wrong, a page is deleted, or someone types a wrong address. Every website has some 404 errors, and it is normal. What matters is how your site handles it.

What a good 404 page does

  • It tells clearly that the page was not found, in friendly words.
  • It gives the visitor a way out: a link to the home page, popular pages, and a search box.
  • It keeps the same design and menu as the rest of the site.
  • It returns the real HTTP status 404, not 200.

Soft 404: a common mistake

If a page shows a “not found” message but the server sends the status 200 (OK), search engines see it as a soft 404. They may waste time on it. Also, redirecting all missing pages to the home page is seen as a soft 404 by Google. Let a missing page be a real 404, or 410 (gone) if it was removed on purpose.

Example of a simple 404 page

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <title>Page not found | Example Site</title>
  <meta name="robots" content="noindex">
</head>
<body>
  <h1>Sorry, we could not find that page</h1>
  <p>The page may have moved or the address may be wrong. Try one of these:</p>
  <ul>
    <li><a href="/">Home page</a></li>
    <li><a href="/seo/">SEO Tutorial</a></li>
    <li><a href="/contact/">Contact us</a></li>
  </ul>
  <form action="/search" method="get">
    <input type="search" name="q" placeholder="Search the site">
    <button>Search</button>
  </form>
</body>
</html>

Set up the 404 page

Apache (.htaccess)

ErrorDocument 404 /404.html

Nginx

error_page 404 /404.html;

PHP

<?php
http_response_code(404);
include 'templates/404.php';
exit;

WordPress

Themes have a 404.php file. You can edit it, or use a plugin or the site editor to design the page. WordPress sends the 404 status by itself.

Find and fix 404 errors

  • Check the Pages report in Google Search Console, which lists “Not found (404)” URLs that Google tried.
  • If the missing page has a good replacement, add a 301 redirect. See Redirection.
  • If other websites link to the missing page, a redirect helps you keep those links.
  • Fix broken internal links in your own pages.

Check the status code

curl -I https://example.com/this-page-does-not-exist/

The first line of the result should be HTTP/2 404.

Note: Do not worry about a few 404 pages. Google says that 404 errors for pages which really do not exist do not hurt the rest of the site. Next: International SEO and Hreflang.

Congratulations! Chapter Finished. Learn more about the similar topics:
Exercises & Assignments
No Content Found.
Interview Questions & Answers
No Content Found.