grav-plugin-sitemap icon indicating copy to clipboard operation
grav-plugin-sitemap copied to clipboard

Way to provide an override for sitemap's lastmod

Open hughbris opened this issue 4 years ago • 1 comments

I submitted a PR (#98) because I thought I'd solved this simply, but I got caught up in a conversation there that threw lots of doubt on my solution. I'm going to bring this back to what I want and the use cases.

The sitemap plugin uses the page object's modified() method to set its lastmod property in the sitemap. This simply grabs the file modification date from the file system.

I want to be able to set lastmod manually at page level, just as it's possible to set changefreq and priority per page in page frontmatter.

Here are a few reasons/use cases:

  • a page file is edited, but only something minor like frontmatter or formatting
  • a site is migrated from another CMS, the file timestamps are recent but the content has not changed
  • data displayed by the page is changed but the page .md file has not been touched. For example, the page contains content sourced from a datasource, a modular child, or displays a gallery which changed.

I thought a page's date frontmatter indicated a manually set modification date and we could simply use that, but I think it may be widely understood to be the page's creation date.

Would it be less ambiguous and cleaner to simply allow setting sitemap.lastmod for each page?

How best to achieve this?

hughbris avatar Aug 24 '21 08:08 hughbris

I was able to do it by editing user/plugins/sitemap/sitemap.xml:287

from:

'lastmod' => date($this->datetime_format, $page->modified()),

to

'lastmod' => date($this->datetime_format, $page->date() ?: $page->modified()),

lordcris avatar Jan 03 '23 23:01 lordcris

@rhukster do you want to close this too due to #113?

chraebsli avatar Jun 14 '24 10:06 chraebsli