How to create a custom 404 page [tutorial]

A 404 error/broken link occurs when someone tries to go to a URL on your site that doesn't exist. The default Quickstart 404 error page shows site visitors a message that says "Page not found," followed by a more detailed explanation that the URL they tried to visit doesn't exist. Often that type of message leaves a visitor confused as to what to do next. The best way to assist site visitors with navigating your site after getting a 404 error is to customize your 404 error page.

Custom 404 page example

Custom 404 page example
Example of a customized 404 error page on Quickstart.

Suggestions for customizing your 404 error page 

Explain what happened

If you decide to create a custom 404 page, ensure that the content explains what happened. Start by including some language that the page they were trying to get to doesn't exist.

Provide some suggestions for what to do next

Help your visitors find what they are looking for. Some suggestions include using site search, browsing the main menu, or using a contact form to reach out to you with questions.

Include popular links

You can include a list of commonly viewed pages on your site to help visitors get to information they are likely looking for.

How to minimize 404 errors

You can't completely eliminate the 404 error experience, because you never know exactly what URL a site visitor may try to visit. You can use a global redirect or other redirect module to try to redirect as many users as possible, but there is still a chance of someone reaching a 404 page.

You can minimize the likelihood of visitors seeing 404 errors with these tips:

  • Test your links - All links you use anywhere on your site should be tested.
  • Run a 404 error/broken link checker - There are many free tools online or Drupal modules you can install to regularly test for broken links.
  • Use Google Webmaster Tools - Google Webmaster comes with a 404 page report that you can review from time to time. It is a good idea to stay on top of any 404 errors reported by Google. When Google encounters a 404 error, it is either from crawling your site and finding an issue, or when crawling external links to your site from other sites. Either way, the link should be corrected through redirection.
  • Use redirects - Use redirects when you make changes to links.

How to create a custom 404 page

  1. Add a flexible page (Add content > Flexible page).
  2. Add your custom content (title, text, images, links, etc.).
  3. Save your page. 
  4. Note the node ID or URL alias of your custom 404 page.
  5. Go to Admin > Configuration > System > Site Information.
  6. Enter the node ID or URL alias in the Error Pages > Default 404 (not found) page field.