Discoverability · Next.js (Pages Router)
How to add a sitemap.xml in Next.js (Pages Router)
A sitemap is how you tell a search engine which pages exist and when they last changed, rather than waiting for every one of them to be found by following links. Without it, pages that are not linked prominently can go months before they are crawled at all.
The fix for Next.js (Pages Router)
13x detects your framework from the response and hands you this version rather than the generic one — below 50% confidence it hedges and gives you the generic one instead.
Use next-sitemap, which is the standard for the Pages Router:
npm i -D next-sitemap// next-sitemap.config.js
module.exports = {
siteUrl: "https://example.com",
generateRobotsTxt: true,
};// package.json
{ "scripts": { "postbuild": "next-sitemap" } }On a different stack? The general version of this fix explains what 13x checks and why it matters, without assuming a framework.
Check your Next.js (Pages Router) site
113 deterministic checks against your live URL, in about 30 seconds. Framework detected from the response, so every fix comes back in the form your stack actually uses.
No signup. Results in 30 seconds.