fix: generate a single clean sitemap.xml, drop @astrojs/sitemap#26
Merged
Conversation
@astrojs/sitemap unconditionally wraps its output in a sitemap-index.xml -> sitemap-N.xml pair, even for a site this small with no real need for the split. The previous fix worked around it by copying the generated sitemap-0.xml over sitemap.xml post-build, but that still left the redundant index/sub-sitemap files sitting in the deployed output alongside the copy -- pure clutter with no purpose once sitemap.xml has everything. Replaced the dependency with a ~30-line postbuild script (scripts/generate-sitemap.mjs) that walks the actual built dist/ directory and writes one flat sitemap.xml directly from the real page files -- no intermediate index, no byproduct files, and it can never drift from the real page set since it reads dist/ after the build completes. 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 wraps output in asitemap-index.xml->sitemap-N.xmlpair — no config option skips this, even for a small 89-page site. The previous fix copiedsitemap-0.xmloversitemap.xml, but the redundant index/sub-sitemap files were still sitting in the deployed output alongside the copy.scripts/generate-sitemap.mjs) that walks the real builtdist/directory and writes one flatsitemap.xmldirectly — no intermediate index, no byproduct files, can't drift from the real page set since it reads the actual build output.Test plan
dist/contains exactly one sitemap file (sitemap.xml), 89 URLs, homepage root URL included/sitemap.xml/sitemap.xmlexists,/sitemap-index.xmland/sitemap-0.xmlnow 404 (expected — they're gone)🤖 Generated with Claude Code