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

Sitemaps: add lastmod for individual posts and the homepage #4901

Closed
wants to merge 5 commits into from

Conversation

swissspidy
Copy link
Member

This resolves the most critical aspect of that Trac ticket for "Last modified".

What it does:

  • Adds lastmod to all individual post objects (of any post type) in the sitemap.
    • This is trivial to add because this information is directly available.
  • Adds lastmod to the homepage sitemap entry if the homepage is set to display the latest posts.
    • This is an approximation that works by fetching the most recent posts (based on their publish date) and then sorting them in PHP by their modified date.

As per my comment, the latter is mostly nice to have but not critical. If we think this approximation is not good enough, we can omit it for now.

What it does not:

  • No lastmod is added for the individual sitemap pages in the sitemap index
  • No lastmod is added for term archives or user archives

Those are difficult to add without any proper mechanism to determine and cache last modified date. As per my comment, this should not be an issue.

Trac ticket: https://core.trac.wordpress.org/ticket/52099


This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.

@swissspidy
Copy link
Member Author

@pbiron Would love to get your review on this one

@swissspidy swissspidy requested a review from joemcgill October 18, 2023 07:50
@swissspidy
Copy link
Member Author

@joemcgill Since you were involved with sitemaps originally, I would appreciate your eyes on this PR.

tl;dr is that lastmod is useful for search engines, so when we can easily expose it (such as for posts and the homepage), we should, but it's also no big deal if it's missing (e.g. for term archives)

Copy link
Member

@joemcgill joemcgill left a comment

Choose a reason for hiding this comment

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

This looks good to me.

It's been several years since I worked on the original proof of concept for this feature, but if memory serves, we initially included lastmod values for these types of pages and ended up removing them for consistency, since some values are difficult to calculate in a performant way. At the time, the guidance we were getting was that these values were not being used as a significant signal by search engines, and extenders were able to filter these values to add lastmod if needed. Here's the PR where the initial implementation was removed.

It's possible that some of those original ideas could be used to further extend the places where core makes lastmod available.

@swissspidy
Copy link
Member Author

Thanks @joemcgill! That's how I remember it too. Now the guidance has slightly changed, and providing lastmod where easily possible is now preferrable.

This PR will close the existing ticket, but a new one can be opened for lastmod elsewhere and whatever is required for that.

@swissspidy
Copy link
Member Author

@swissspidy swissspidy closed this Oct 23, 2023
@swissspidy swissspidy deleted the fix/52099-lastmod branch October 23, 2023 16:56
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.

2 participants