fix: make /sitemap.xml list all pages directly, not an index-of-one#25
Merged
Conversation
@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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
@astrojs/sitemapunconditionally emits a sitemapindex wrapper — there's no config option to make it skip that for a small site. My previous fix pointed/sitemap.xmlat 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.postbuildscript that copies the real, already-transformedsitemap-0.xmloversitemap.xmlafter every build — always complete, always in sync with the actual page set, no manual/static duplication to go stale./sitemap.xmldirectly.Test plan
dist/sitemap.xmlcontains all 89<loc>entries directly (verified via build log + grep count)🤖 Generated with Claude Code