Fix sitemap <lastmod> missing when metadata.updated_at is absent#145
Conversation
|
Thanks for this @m-lague ❤️ Dug a bit into the lastmod tag.
So
Given above this is not correct behaviour. So while on this, I think it would be good to fix this as it could/would harm sites using Perron's sitemaps. Other relevant links: |
|
Yes, I had indeed noted this point and wanted to discuss it. As you pointed out, having all So maybe we should remove the line entirely : with.lastmod Time.current.iso8601 and instead add a note in the documentation stating that |
|
That is the way to go, indeed. No I will add a note about updating the sitemap docs to mention |
|
@m-lague I updated the PR to remove the Thanks for your first contribution to Perron! ❤️ |
Fixes #143
When a resource doesn't have
metadata.updated_at, therescueblockwas evaluating
Time.current.iso8601but not passing it towith.lastmod,so
<lastmod>was silently omitted from the sitemap.Adding
with.lastmod Time.current.iso8601in therescuebranch ensuresthe tag is always written, either with the resource's own date or with
the current build time as fallback.
Also added
updated_atto a dummy post to cover both cases in the tests:updated_at→<lastmod>uses that dateupdated_at→<lastmod>falls back to current timeTwo new tests added in
test/perron/site/builder/sitemap_test.rb, both passing:test_sitemap_uses_resource_updated_at_as_lastmod_when_presenttest_sitemap_falls_back_to_current_time_as_lastmod_when_updated_at_is_missing