getgrav / grav-plugin-sitemap

Grav Sitemap Plugin
https://getgrav.org
MIT License
42 stars 42 forks source link

Way to provide an override for sitemap's lastmod #99

Closed hughbris closed 1 month ago

hughbris commented 2 years ago

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:

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?

lordcris commented 1 year ago

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()),

chraebsli commented 1 month ago

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