question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add lastmod to sitemap

See original GitHub issue

🐛 Bug Report

The XML sitemaps currently output loc, changefreq and priority for every url set. I would propose dropping the changefreq and priority fields, as none of the search engines use these, and instead adding the lastmod field, with the last modification date of the file.

Have you read the Contributing Guidelines on issues?

Yes.

To Reproduce

(Write your steps here:)

  1. Open any DocuSaurus v2 sitemap 😃

Expected behavior

The current output would be:

<url>
        <loc>https://developer.yoast.com/features/canonical-urls/api</loc>
        <changefreq>weekly</changefreq>
        <priority>0.5</priority>
</url>

(Write what you thought would happen.)

Actual Behavior

I propose changing it to:

<url>
        <loc>https://developer.yoast.com/features/canonical-urls/api</loc>
        <lastmod>2020-04-14T11:22:05+00:00</lastmod>
</url>

Your Environment

  • Docusaurus version used: v2

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:2
  • Comments:10 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
jdevalkcommented, Oct 23, 2020

If this info can’t be obtained (pages might not be generated from FS files), is it better to not add the lastmod entry, or to fallback to build time (which is likely to be a recent value if the site is built often).

I would not add it then. Having it change all the time when it’s actually not changing is also not beneficial.

We agree that this date should rather be updated when the content change, but not when the code (ie the layout rendering the content etc) change?

Agreed.

1reaction
slorbercommented, Oct 23, 2020

Thanks, will do that.

About lastModified, some plugins already read git history to get the last modified date. We can enable also to hardcode it through frontmatter.

I think we should:

  • call addRoute apis with lastModified: lastModifiedFrontmatter || lastModifiedGit || lastModifiedFS || undefined
  • use that data when generating the sitemaps. If not available, add the date of the build?

If this info can’t be obtained (pages might not be generated from FS files), is it better to not add the lastmod entry, or to fallback to build time (which is likely to be a recent value if the site is built often).

We agree that this date should rather be updated when the content change, but not when the code (ie the layout rendering the content etc) change?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Add <lastmod> tag to every entry in the Sitemap
How to add a <lastmod> tag to every entry in the Sitemap so that the last modified date of the items is included?...
Read more >
XML Sitemap: the ultimate reference guide | ContentKing
An XML Sitemap is a special document which lists all pages on a website to provide search engines with an overview of all...
Read more >
Add and automatically update <lastmod> tag in sitemap - SEO
Hi Guys, Is there any possibility to add a tag to my sitemap and automatically update it every time I publish my site?...
Read more >
Protocol - sitemaps.org
The optional <lastmod> tag is also available for Sitemap index files. ... the list into multiple text files and add each one separately....
Read more >
how to add lastmod field in index sitemap django
I did some research, and modified generic function index: def index(request, sitemaps, template_name='sitemap_index.xml', ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found