Sync sitemap lastmod dates with spec entry updated field#1
Merged
Conversation
Configure @astrojs/sitemap with a serialize function that sets each URL's <lastmod> from the spec entry's updated front matter (the same source the RSS feed uses), so the date reflects real content changes rather than the build timestamp. Category indexes track their newest entry; collection-wide surfaces (/, /spec/, /checklist/) track the newest entry overall. Document the worked example on the XML sitemaps spec page.
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.
What this changes
Implements dynamic sitemap generation that derives
<lastmod>dates from theupdatedfront matter field of spec entries, rather than using build timestamps. This ensures the sitemap stays in sync with actual content changes and matches the source of truth already used by the RSS feed.Code changes:
astro.config.mjs: AddedbuildLastmodMap()function that parses all spec entry front matter to extractupdateddates and builds a canonical URL → lastmod map. Integrated into the sitemap serializer to populate<lastmod>for each URL.src/content/spec/seo/xml-sitemaps.md: Added a "This site ships it" section documenting thatspecification.websitenow generates sitemaps with accurate lastmod dates derived from content, not build time.The implementation:
.mdand.mdxfiles undersrc/content/spec/updated,category, andslugfrom YAML front matter/,/spec/,/checklist/) to the newest entry's date across the whole collection@astrojs/sitemap'sserialize()hook to inject ISO 8601 datesSources
<lastmod>specificationChecklist
npm run buildpasses locally.https://claude.ai/code/session_016DgaQscUXMFQBcJX9Q1J63