Technical·Cursor
TechnicalCursor

Add a custom 404 pageCursor

A default 404 bounces users. A custom 404 with navigation and search keeps them on the site and reduces bounce rate.

rocket_launch

Fixing this in Cursor

Agentic AI code editor built on VSCode

In Next.js App Router, create `app/not-found.tsx`. For per-route 404s, add `not-found.tsx` in the route segment.

Using a different tool? Pick your stack:

The prompt for Cursor

Copy and paste this into your Cursor chat exactly as-is.

Apply these changes to my codebase. Edit the files directly and keep existing formatting:

Add a custom 404 page

1. Create app/not-found.tsx with a helpful 404 page that links back to the homepage.

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 Cursor

  1. 1. Open your Cursor project.
  2. 2. Copy the prompt above with the copy button.
  3. 3. Paste into the Cursor chat and send.
  4. 4. Review the diff, accept the changes, redeploy.
  5. 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
No. The 404 HTTP status tells Google not to index. Do not add robots meta to prevent it — status is enough.
Can I add analytics to 404s?expand_more
Yes — helpful to see which broken links come from. Track as a pageview or a custom event.

Want all 34 prompts tailored to your Cursor 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 site

Related Cursor prompts