October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsClean PCRecommendedOne scan can reveal what keeps slowing WindowsLook for cleanup and repair opportunities.Run ScanOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
World desk4 min

Free 404 and Error Page Templates: Copy-Paste HTML and Setup Guide

A copy-ready HTML/CSS 404 page plus practical setup guidance for GitHub Pages, Apache, and other deployments—with checks to ensure the error is clear and the HTTP status is correct.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

A custom 404 page can explain what went wrong and give visitors a useful way back—but the design alone does not make a URL return the correct HTTP status. This guide includes a copy-ready HTML/CSS template, explains how to connect it on GitHub Pages or Apache, and shows what to check before you treat a 404 as a design problem.

What a 404 page should do

HTTP 404 means the server cannot find the requested resource. It does not, by itself, mean the page has been permanently removed. For content that has been permanently removed, MDN identifies HTTP 410 Gone as the distinct status: MDN’s 404 reference.

As an Amazon Associate I earn from qualifying purchases.

A useful error page states plainly that the requested page could not be found, then offers a recovery route. A home link is a sensible minimum; site search or links to relevant sections can help too. A joke or distinctive visual style is fine as long as it does not obscure the explanation. MDN puts it this way: “Feel free to make your 404 page humorous and human, but don’t confuse your visitors as to why they are seeing something unexpected.”

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Copy-paste 404 template: plain HTML and CSS

This starter uses no JavaScript, framework, images, or external fonts. Save it as an HTML file, then change the site name, colors, text, and home URL to fit your site. The home link is the recovery route; add a search form or useful section links if your site supports them.

#1 Best Overall
Sale
HTML and CSS: Design and Build Websites
  • HTML CSS Design and Build Web Sites
  • Comes with secure packaging
  • It can be a gift option
<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>Page not found | Example Site</title>
  <style>
    :root {
      color-scheme: light;
      font-family: system-ui, sans-serif;
      color: #172033;
      background: #f5f7fb;
    }
    * { box-sizing: border-box; }
    body {
      min-height: 100vh;
      margin: 0;
      display: grid;
      place-items: center;
      padding: 1.5rem;
    }
    main {
      width: min(100%, 42rem);
      padding: clamp(1.5rem, 5vw, 3rem);
      border: 1px solid #d9e0ec;
      border-radius: 1rem;
      background: #fff;
      text-align: center;
    }
    h1 { margin: 0 0 1rem; font-size: clamp(2rem, 7vw, 3.5rem); }
    p { line-height: 1.6; }
    a {
      display: inline-block;
      margin-top: 1rem;
      padding: .75rem 1rem;
      border-radius: .5rem;
      background: #174ea6;
      color: #fff;
      text-decoration: none;
    }
    a:hover { background: #103c82; }
    a:focus-visible { outline: 3px solid #f0a500; outline-offset: 3px; }
  </style>
</head>
<body>
  <main>
    <p>404 — Page not found</p>
    <h1>We can’t find that page.</h1>
    <p>The address may be incorrect, or the page may have moved.</p>
    <a href="/">Go to the homepage</a>
  </main>
</body>
</html>

The markup provides a heading, readable explanation, and keyboard-visible focus style for its link. Review colors and layout against your own accessibility requirements, and test on narrow screens and with a keyboard; a code sample is not a substitute for checking the deployed page.

Choose a template style without mistaking a demo for a deployable page

Template collections surface a wide range of ideas, including terminal, pixel-art, dark, space, cartoon, brutalist, luxury, and glass-inspired designs. GitHub’s error-page-template topic is a discovery index, not a verified or licensed catalog. It does not establish that a given entry works, is accessible, or can be reused under your terms.

Rank #2
Sale
Web Design with HTML, CSS, JavaScript and jQuery Set
  • Brand: Wiley
  • Set of 2 Volumes
  • A handy two-book set that uniquely combines related technologies Highly visual format and accessible language makes these books highly effective learning tools Perfect for beginning web designers and front-end developers
  • Check dependencies: determine whether the page is standalone HTML/CSS or relies on JavaScript, a framework, fonts, images, or other assets.
  • Check recovery behavior: confirm that links, search, and navigation point to real destinations on your site.
  • Check responsive and accessible behavior: test the actual page for keyboard access, legible contrast, mobile layout, and reduced-motion handling where animation is used. Do not infer these qualities from a screenshot.
  • Check reuse terms: read the project’s license and confirm that its assets are included and permitted for your intended use.
  • Check the HTTP response: verify that an unknown URL returns status 404, not a normal 200 response displaying error-page text.

Connect the page to your platform or server

A custom page is only the presentation layer. The hosting platform or server must route missing URLs to it while returning the appropriate error status. The configuration depends on where the site is published.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

GitHub Pages

  1. Put a file named 404.html in the publishing source for the site.
  2. Alternatively, create 404.md with YAML front matter setting permalink: /404.html.
  3. Commit the file to the repository’s publishing source. Follow GitHub’s custom 404 instructions for the current publishing setup.
  4. After deployment, request a URL that does not exist and check that the custom page appears and the response is still 404.

Apache

MDN’s Apache example maps the error to a local page with an .htaccess directive:

ErrorDocument 404 /notfound.html

Place the target page at the corresponding local path and ensure the server can serve it. See MDN’s 404 reference for the example and context.

Other servers and application frameworks

HttpErrorPages is a project option for generating error pages and adapting them to deployments. Its documentation describes static output and examples involving Nginx, Apache HTTPD, Lighttpd, Express, Koa, and Caddy, with customization through templates and language definitions. Treat it as a starting point, not a universal install: check its current requirements and configure the relevant server or application integration for your environment.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

If GitHub Pages shows a 404 unexpectedly

Do not assume the error is caused by the appearance of the page. GitHub’s troubleshooting guide identifies several possible causes to inspect, including platform status, DNS, browser cache, the location and capitalization of index.html, publishing-source contents, custom-domain configuration, and repository or publishing conditions. Work through GitHub’s troubleshooting steps to distinguish a site-wide publishing problem from a single missing route.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Before you publish

  • Use an explicit message that the requested page was not found.
  • Make the primary recovery link work from the location where the error page is served; adapt root-relative paths if your site is published under a project subpath.
  • Copy every required asset and verify all links and scripts on the deployed site.
  • Test an actually missing URL and confirm both the visible page and HTTP status code.
  • For removed content, decide whether it is truly permanent rather than treating every missing URL as equivalent.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Crashes, No Sound, or Screen Glitches?Free driver scan
PC Slower Than It Used to Be?Free scan - under a minute

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.