Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(sitemap): add support for "lastmod" #9954

Merged
merged 18 commits into from
Mar 20, 2024
Merged

Conversation

slorber
Copy link
Collaborator

@slorber slorber commented Mar 15, 2024

Motivation

Fix #2604

Add new sitemap options:

{
  lastmod: null | 'date' | 'datetime'
  priority: null,
  changefreq: null,
}
  • Add a new sitemap option lastmod that permits to output <lastmod> tags in the sitemap, formatted as YYYY-MM-DD date, or ISO datetime
  • Allow to disable useless <changefreq> and <priority> sitemap tags (Google doesn't use them) with null values

Important notes:

  • lastmod only works for routes backed and requires plugin authors to add new route metadata when calling addRoute()
  • All our official content plugins provide this route metadata
  • If plugins allow to provide a last updated time as front matter, then it's possible for the sitemap plugin to use this explicit date in priority. Otherwise, a timestamp will be inferred from the Git history of the content source file.
  • We are able to output a <lastmod> tag for React page components as well. However it will only use the React page source Git history, and will not check history of its dependencies.
  • Not all routes will have a <lastmod> tag. If a third-party plugin does not provide the new metadata, the sitemap can't infer a proper value. According to Google recommendations, it's only relevant to use <lastmod> tags for routes backed by content, and not routes aggregating multiple documents (tags, blog pagination, blog archive, doc autogenerated index...)

Test Plan

Unit tests + dogfood on our website

Test links

Related issues/PRs

Supersed PR #9234

@slorber slorber added pr: new feature This PR adds a new API or behavior. to backport This PR is planned to be backported to a stable version of Docusaurus labels Mar 15, 2024
@facebook-github-bot facebook-github-bot added the CLA Signed Signed Facebook CLA label Mar 15, 2024
@slorber slorber mentioned this pull request Mar 15, 2024
3 tasks
@slorber slorber changed the title feat(sitemap): feat(sitemap): add support for "lastmod" Mar 15, 2024
Copy link

netlify bot commented Mar 15, 2024

[V2]

Name Link
🔨 Latest commit d92d80d
🔍 Latest deploy log https://app.netlify.com/sites/docusaurus-2/deploys/65fabb7a60eb5c00078573c5
😎 Deploy Preview https://deploy-preview-9954--docusaurus-2.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link

github-actions bot commented Mar 15, 2024

⚡️ Lighthouse report for the deploy preview of this PR

URL Performance Accessibility Best Practices SEO PWA Report
/ 🔴 46 🟢 98 🟢 96 🟢 100 🟠 88 Report
/docs/installation 🟠 59 🟢 96 🟢 100 🟢 100 🟠 88 Report
/docs/category/getting-started 🟠 76 🟢 100 🟢 100 🟢 90 🟠 88 Report
/blog 🟠 69 🟢 100 🟢 100 🟢 90 🟠 88 Report
/blog/preparing-your-site-for-docusaurus-v3 🟠 59 🟢 96 🟢 100 🟢 100 🟠 88 Report
/blog/tags/release 🟠 71 🟢 100 🟢 100 🟠 80 🟠 88 Report
/blog/tags 🟠 76 🟢 100 🟢 100 🟢 90 🟠 88 Report

Copy link

github-actions bot commented Mar 15, 2024

Size Change: +45 B (0%)

Total Size: 992 kB

Filename Size Change
website/build/assets/js/main.********.js 765 kB +45 B (0%)
ℹ️ View Unchanged
Filename Size
website/.docusaurus/globalData.json 75.4 kB
website/build/assets/css/styles.********.css 114 kB
website/build/index.html 37.9 kB

compressed-size-action

@slorber slorber marked this pull request as ready for review March 19, 2024 16:02
@slorber slorber requested a review from Josh-Cena as a code owner March 19, 2024 16:02
@slorber slorber mentioned this pull request Mar 19, 2024
Copy link
Contributor

@johnnyreilly johnnyreilly left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is excellent work; I like that you're looking to make the default sitemap include lastmod by default with Docusaurus v4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed Signed Facebook CLA pr: new feature This PR adds a new API or behavior. to backport This PR is planned to be backported to a stable version of Docusaurus
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add lastmod to sitemap
5 participants