Skip to content

feat(sitemap): add accurate lastmod from each doc's last content change - #928

Open
amaan-bhati wants to merge 1 commit into
mainfrom
feat/sitemap-lastmod
Open

amaan-bhati wants to merge 1 commit into
mainfrom
feat/sitemap-lastmod

Conversation

@amaan-bhati

Copy link
Copy Markdown
Member

What has changed?

Adds an accurate <lastmod> to the docs sitemap, and fixes the "Last updated" date and dateModified on every doc page.

Before this PR:

  • The sitemap had no <lastmod> (the sitemap plugin's lastmod option was unset).
  • The deploy checkout was shallow (fetch-depth: 1), so every page reported the date of the newest commit. Live check: every page I sampled had the same dateModified (2026-10-11).

What this PR does:

  • Content-based last-update date (src/lastUpdate/contentLastUpdate.js): for each doc, walks git history and uses the last commit that changed the Markdown body.
    • Skips front-matter-only and whitespace-only commits.
    • Follows copies and renames, so cutting a docs version (e.g. v3 to v4) does not reset every page's date.
    • Commits that change bodies without changing meaning can be listed in .lastmod-ignore-revs (works like .git-blame-ignore-revs).
    • A hand-written last_update.date in front matter still wins.
    • Injected through markdown.parseFrontMatter, so no doc files change.
  • Sitemap: lastmod: "date" in the sitemap plugin config.
  • CI: fetch-depth: 0 in main.yml (deploy) and build_and_check.yml (PR preview).
  • Safe fallback: in dev, with DOCUSAURUS_DISABLE_LAST_UPDATE, or in a shallow clone, it logs a warning and falls back to Docusaurus's default behaviour.

Why: Google and Bing use <lastmod> only when it is consistently accurate. Dates that move without real changes get ignored for the whole sitemap.

Type of change

  • New feature (non-breaking change which adds functionality).
  • Bug fix (non-breaking change which fixes an issue).

How Has This Been Tested?

Checklist:

  • My code follows the style guidelines of this project.
  • I have performed a self-review of my own code.

This branch has not been deployed

No deployments
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.

1 participant