How to fix page not found on Headless / Custom (I build in code)

Fix broken internal links pointing to pages that return a 404 error by either removing those links or setting up a 301 redirect from the missing URL to the correct replacement page.

Steps for Headless / Custom (I build in code)

  1. In your server or framework configuration (e.g. Next.js next.config.js, Nuxt redirects, Nginx, Apache .htaccess), add a 301 redirect rule from the old URL to the new destination.
  2. Search your codebase (components, templates, CMS content) for any hard-coded references to the old broken URL and replace them with the correct destination URL.
  3. If using a headless CMS (Contentful, Sanity, Storyblok, etc.), update or remove the broken links directly in that CMS's content editor.
  4. Deploy the changes and verify with a curl command: `curl -I https://yourdomain.com/old-url` — you should see `HTTP/1.1 301` and a `Location:` header pointing to the new URL.
  5. Submit the updated sitemap to Google Search Console to prompt re-crawling.
Official Headless / Custom (I build in code) documentation ↗

What is page not found?

A 404 ("Page Not Found") error means a URL on your store no longer exists — but other pages on your site still link to it. Every time a shopper or search engine follows one of those links, they hit a dead end instead of useful content. This can happen when you delete a product, rename a collection, restructure your URLs, or migrate to a new platform without properly redirecting old addresses.

Search engines like Google treat 404 pages as dead ends: any ranking authority ("link equity") that flowed through those internal links is wasted instead of boosting the destination page. Googlebot also has a limited crawl budget — time spent re-crawling broken URLs is time not spent discovering your new or best-selling pages, which can slow indexing and hurt rankings. For shoppers, clicking a link and landing on a 404 page destroys trust, interrupts the purchase journey, and directly costs you sales. If enough 404s accumulate, Google can downgrade its overall assessment of your site's quality.

See the complete Page not found guide for every platform and the full background.

Not sure if your Headless / Custom (I build in code) store has this?

Run a free SEOLZ scan — we’ll find page not found and every other issue across your whole site.

Scan my site free

Fix page not found on another platform