Way to provide an override for sitemap's lastmod
hughbris opened this issue · 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?
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()),