@astrojs/sitemap doesn't generate sitemap.xml
31 May 2026Wired up @astrojs/sitemap on an Astro project, built it, and went looking for dist/sitemap.xml. Wasn’t there. What I found instead: sitemap-index.xml and sitemap-0.xml. No bug — that’s the documented default. The integration always emits a sitemap index plus one or more chunked sitemap files, even when the site is tiny enough to fit in a single file.
The annoying part is that every robots.txt convention, every SEO tool, and most crawlers happily look for /sitemap.xml first. Renaming the index doesn’t work either — the index points at sitemap-0.xml by absolute URL, so you can’t just rename one file without rewriting the references.
Cheapest fix is a postbuild step that copies sitemap-index.xml to sitemap.xml so both URLs resolve. The internal references in the index stay valid, and any tool hitting /sitemap.xml lands on the index. Three lines in package.json:
"scripts": {
"build": "astro build",
"postbuild": "cp dist/sitemap-index.xml dist/sitemap.xml"
}
Less code, but worth knowing if you ever wonder why your freshly-deployed Astro site has a sitemap that nothing seems to find: it’s there, it’s just not where the convention says it should be.