Replies: 1 comment
|
You can do achieve this by using https://inox-tools.fryuni.dev/sitemap-ext and custom integrations, but I agree it is not ideal |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Feature Request: Per-page
lastmodfrom source file metadata (git history / frontmatter)Current Behavior
@astrojs/sitemapsupports a top-levellastmodoption that stamps every page with the same date:This is misleading for sites where only a subset of pages changes per build, because search engines receive inaccurate signals about which content is fresh.
The
serialize()escape hatch allows per-page customization, but users must manually reverse-map everyitem.urlback to its source file and run their owngit log/fs.statlogic. This is boilerplate-heavy and error-prone, especially for content-heavy sites with hundreds of pages and nested content collections.Use Case
We run a documentation site (Starlight +
@astrojs/sitemap) with ~700 pages. Only a few articles change per deployment, but the current setup forces us to either:lastmodentirely (loses crawl-priority signals for updated pages)We want each
<url>entry to carry the actual last modification date of its source file.Prior Art
Starlight already solves the same problem for page footers via
lastUpdated:git logquery to get the newest commit date per file.lastUpdatedfrontmatter field for manual override.However, this computed date is not exposed to
@astrojs/sitemapor any other integration, so it cannot be reused for the sitemap.Proposed Solutions
Option A —
lastmodSourcecallback in@astrojs/sitemapAllow users to provide a function that maps each page URL to its
lastmodvalue beforeserialize()is called:This keeps the integration framework-agnostic while removing the need for boilerplate
serialize()code.Option B — Astro integration API: expose source file path in
astro:build:doneIf the
pagesarray inastro:build:doneincluded a reference to the source file path (e.g.,src/content/docs/foo.mdx),@astrojs/sitemapcould optionally derivelastmodautomatically from git history or filemtime. This would benefit any integration that needs source metadata, not just sitemaps.Option C — Re-use frontmatter / content collection metadata
If
@astrojs/sitemapcould access the parsed frontmatter of each page (or the content collection entry), users could set alastmod/lastUpdatedfield in frontmatter and the integration could pick it up automatically—similar to how RSS feeds consume frontmatter dates.Environment
@astrojs/sitemap: 3.xAdditional Context
changefreqandpriority, but still useslastmodfor crawl scheduling.serialize()+child_process.execSync('git log')), but they add maintenance burden and are slow when done per-page instead of in bulk.lastUpdatedfeature).Also filed as issue #16803 on the main repo.
All reactions