Skip to content

fix: make /sitemap.xml list all pages directly, not an index-of-one#25

Merged
enricopiovesan merged 1 commit into
mainfrom
fix/sitemap-flat-urlset
Jul 11, 2026
Merged

fix: make /sitemap.xml list all pages directly, not an index-of-one#25
enricopiovesan merged 1 commit into
mainfrom
fix/sitemap-flat-urlset

Conversation

@enricopiovesan

Copy link
Copy Markdown
Collaborator

Summary

  • @astrojs/sitemap unconditionally emits a sitemapindex wrapper — there's no config option to make it skip that for a small site. My previous fix pointed /sitemap.xml at a static copy of that index, so it only showed one <loc> entry (the index's single child sitemap), not the 89 real page URLs a human would expect to see.
  • Replaced that with a postbuild script that copies the real, already-transformed sitemap-0.xml over sitemap.xml after every build — always complete, always in sync with the actual page set, no manual/static duplication to go stale.
  • Updated robots.txt to point at the simpler /sitemap.xml directly.

Test plan

  • Build output: dist/sitemap.xml contains all 89 <loc> entries directly (verified via build log + grep count)
  • curl /sitemap.xml on production shows 89 URLs after deploy

🤖 Generated with Claude Code

@astrojs/sitemap unconditionally emits a sitemapindex wrapper
(sitemap-index.xml -> sitemap-0.xml) regardless of site size -- there
is no config option to skip it. That's valid per the sitemap protocol
and every real crawler follows the reference automatically, but it
meant /sitemap.xml (which I'd pointed at a static copy of the index
in the previous fix) only showed one <loc> entry, not the 89 real
page URLs, which is what a human clicking the link reasonably expects
for a site this size.

Replaced the static placeholder with a postbuild step that copies the
real, already-serialize()-transformed sitemap-0.xml over sitemap.xml
after every build, so it's always the complete, correct, and never-
stale list of all pages -- generated fresh each build from the actual
page set, not hand-maintained. Updated robots.txt to point at the
simpler /sitemap.xml directly.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@enricopiovesan enricopiovesan merged commit 839447f into main Jul 11, 2026
2 checks passed
@enricopiovesan enricopiovesan deleted the fix/sitemap-flat-urlset branch July 11, 2026 15:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant