Add a custom 404 page — Claude Code
A default 404 bounces users. A custom 404 with navigation and search keeps them on the site and reduces bounce rate.
Fixing this in Claude Code
Anthropic's official terminal coding agent
Claude Code can grep the whole codebase first, plan the change, then edit every affected file. Paste the prompt below into your Claude Code chat and the fix rolls out across the project in one pass.
Using a different tool? Pick your stack:
The prompt for Claude Code
Copy and paste this into your Claude Code chat exactly as-is.
Run Claude Code in the project root and make these exact changes, scanning the whole codebase first: Add a custom 404 page 1. Create a custom 404 page that helps users navigate back to working pages.
Why this matters
About 1-5% of page loads hit a 404 on most sites (typos, stale links, Googlebot discovery errors). A default bare "404 Not Found" bounces 90%+ of those visitors.
A custom 404 with search and a few popular links keeps users engaged and preserves SEO value — they do not leave Google's "dwell time" signal tanked.
How to use this prompt in Claude Code
- 1. Open your Claude Code project.
- 2. Copy the prompt above with the copy button.
- 3. Paste into the Claude Code chat and send.
- 4. Review the diff, accept the changes, redeploy.
- 5. Verify the fix using the checklist below.
Common mistakes to avoid
- error_outlineReturning 200 status for the 404 page — creates "soft 404" and confuses Google.
- error_outlineShowing only "Not Found" with no helpful links or search.
- error_outlineMissing the 404 status header even if the page is correct.
How to verify the fix worked
- check_circle`curl -I https://yoursite.com/nonexistent` returns 404 status.
- check_circleVisit a non-existent URL — branded 404 with search and links.
- check_circleGoogle Search Console → Not Found report — no "soft 404" flags.
Frequently asked questions
Should 404 pages be indexed?expand_more
Can I add analytics to 404s?expand_more
Want all 34 prompts tailored to your Claude Code site?
Pantra scans your site in 10 seconds, detects the stack, and generates the exact prompts that apply — only the ones you actually need.
Scan my siteRelated Claude Code prompts
Fix broken internal links — Claude Code
Prompt to scan for 404s on internal links and fix or redirect them — SEO and UX win.
TechnicalAdd the viewport meta tag — Claude Code
Prompt to add the mobile-friendly viewport meta tag — required for Google mobile-first indexing.
TechnicalSet the lang attribute on <html> — Claude Code
Prompt to add lang="en" or lang="de" to the <html> tag for accessibility and SEO.
TechnicalDeclare UTF-8 charset — Claude Code
Prompt to add <meta charset="utf-8"> at the top of <head> to avoid broken characters.