Skip to content

Sync sitemap lastmod dates with spec entry updated field#1

Merged
jdevalk merged 1 commit into
mainfrom
claude/xml-sitemap-lastmod-3yhMo
May 29, 2026
Merged

Sync sitemap lastmod dates with spec entry updated field#1
jdevalk merged 1 commit into
mainfrom
claude/xml-sitemap-lastmod-3yhMo

Conversation

@jdevalk
Copy link
Copy Markdown
Owner

@jdevalk jdevalk commented May 29, 2026

What this changes

Implements dynamic sitemap generation that derives <lastmod> dates from the updated front 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: Added buildLastmodMap() function that parses all spec entry front matter to extract updated dates 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 that specification.website now generates sitemaps with accurate lastmod dates derived from content, not build time.

The implementation:

  • Reads all .md and .mdx files under src/content/spec/
  • Extracts updated, category, and slug from YAML front matter
  • Skips draft entries
  • Maps individual spec URLs and category index pages to their respective lastmod dates
  • Sets root-level pages (/, /spec/, /checklist/) to the newest entry's date across the whole collection
  • Passes the map to @astrojs/sitemap's serialize() hook to inject ISO 8601 dates

Sources

Checklist

  • Sources cited on changed page.
  • Status is honest (page documents existing implementation).
  • Platform-agnostic — describes the outcome (accurate lastmod dates), not implementation details.
  • npm run build passes locally.
  • No accidental dependencies added (uses only Node.js built-ins and existing Astro integration).

https://claude.ai/code/session_016DgaQscUXMFQBcJX9Q1J63

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.
@jdevalk jdevalk merged commit 12a630d into main May 29, 2026
2 checks passed
@jdevalk jdevalk deleted the claude/xml-sitemap-lastmod-3yhMo branch May 29, 2026 14:08
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.

2 participants