WordPress.org

Make WordPress Core

Opened 3 months ago

Closed 2 months ago

#52099 closed enhancement (wontfix)

Sitemaps "Last Modified" (lastmod) tag

Reported by: junaidbhura Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version: 5.5
Component: Sitemaps Keywords: has-patch has-unit-tests
Focuses: Cc:

Description

Sitemaps currently only support the "Location" tag (loc). This ticket adds support for the "Last Modified" tag.

This is how it works:

1. Posts

This is probably the easiest - it just takes the post_modified_gmt value of the post and creates a lastmod tag.

2. Taxonomies

It gets the latest modified post in the taxonomy and creates a lastmod tag based on its last modified value.

3. Users

It gets the latest modified post by a user and creates a lastmod tag based on its last modified value.

4. Indices

Sitemap indices / indexes work in this way:

  1. If its a post index - get the last modified date of the last updated post in the post type
  2. If its a taxonomy index - get the last modified date of the last updated post which is associated with any term in the taxonomy
  3. If its a user index - get the last modified date of the post type "post" - since all posts are associated with users

Attachments (2)

52099.diff (12.1 KB) - added by junaidbhura 3 months ago.
52099.2.diff (12.1 KB) - added by junaidbhura 3 months ago.

Download all attachments as: .zip

Change History (8)

@junaidbhura
3 months ago

This ticket was mentioned in PR #822 on WordPress/wordpress-develop by junaidbhura.


3 months ago

  • Keywords has-unit-tests added

#2 @prbot
3 months ago

github-actions[bot] commented on PR #822:

Hi @junaidbhura! 👋

Thank you for your contribution to WordPress! 💖

It looks like this is your first pull request to wordpress-develop. Here are a few things to be aware of that may help you out!

No one monitors this repository for new pull requests. Pull requests must be attached to a Trac ticket to be considered for inclusion in WordPress Core. To attach a pull request to a Trac ticket, please include the ticket's full URL in your pull request description.

Pull requests are never merged on GitHub. The WordPress codebase continues to be managed through the SVN repository that this GitHub repository mirrors. Please feel free to open pull requests to work on any contribution you are making.

More information about how GitHub pull requests can be used to contribute to WordPress can be found in this blog post.

Please include automated tests. Including tests in your pull request is one way to help your patch be considered faster. To learn about WordPress' test suites, visit the Automated Testing page in the handbook.

If you have not had a chance, please review the Contribute with Code page in the WordPress Core Handbook.

The Developer Hub also documents the various coding standards that are followed:

Thank you,
The WordPress Project

#3 @junaidbhura
3 months ago

Hey @peterwilsoncc do you think you could take a look at this and let me know what you think?

https://github.com/WordPress/wordpress-develop/pull/822

@junaidbhura
3 months ago

#4 @MadtownLems
3 months ago

I believe that this was intentionally left in plugin territory, at least partially because "last modified" for a post can be much more complicated than this when you consider dynamic content.

If a page's primary function is to embed a YouTube playlist, twitch channel, etc - the page gets new content whenever those things update.

The same is true for pages that pull content from other sources, such as a third party calendaring system, RSS feeds, or even just using the Latest Posts block.

Furthermore, most search engines don't actually consume these other tags.

Here's an excerpt from the blog post announcing the new functionality (https://make.wordpress.org/core/2020/07/22/new-xml-sitemaps-functionality-in-wordpress-5-5/):

"The sitemaps protocol specifies a certain set of supported attributes for sitemap entries. Of those, only the URL (loc) tag is required. All others (e.g. changefreq and priority) are optional tags in the sitemaps protocol and not typically consumed by search engines, which is why WordPress only lists the URL itself. Developers can still add those tags if they really want to."

#5 @pbiron
3 months ago

  • Version changed from 5.6 to 5.5

Version 0.2.0 of the core sitemaps feature plugin was the last one to include support for lastmod.

All support for lastmod was removed in Remove all traces of lastmod, PR 145.

You can check out that PR, which contains links to the issues and slack conversations around that.

In addition to what @MadtownLems mentions, in large sites lastmod can be expensive to compute.

#6 @junaidbhura
2 months ago

  • Resolution set to wontfix
  • Status changed from new to closed

Didn't realise that it was purposely left out - thanks for pointing this out. I'll close this ticket out!

Note: See TracTickets for help on using tickets.