Category: SEO and Google Search

Next.js: /sitemap.xml returns 404 after implementation

Read this guide in Polish

In the local environment, the site map exists, but under the production domain returns HTTP 404. Sitemap route may not be part of the build or URL indicates another environment or application.

How to determine the source of the error

Check directly https://domena/sitemap.xml and SHA implementation on Vercel.

Determine whether the application uses app/sitemap.ts, a file in public/ or an external generator.

What to do step by step

1. Add or correct the correct App Router metadata route or place a static file in public/. Do not confuse the sitemap.xml file in the public directory with the metadata route, because their simultaneous use may create a conflict.

2 . Make sure the domain is attached to the correct design and there is no rewrite intercepting /sitemap.xml.

How to check the score

The production URL returns HTTP 200 and XML with real canonical addresses.

What to do

Do not report in Search Console an address that the server does not publicly share.