Dead simple Jekyll plugin to return the last modified date of a file. Useful to build a better sitemap.xml :)
Copy jekyll-last-modified.rb
into the /_plugins/
directory of your Jekyll project.
The plugin adds a new custom liquid tag, which can be used as follows:
{% last_modified /myfile/index.html %}
You can also use liquid objects within the tag:
{% last_modified {{ post.path }} %}
I’m using the plugin on My Morning Routine to use the last modified date for <lastmod>
in our sitemap.xml:
<lastmod>{% capture lastmod_date %}{% last_modified {{ post.path }} %}{% endcapture %}{{ lastmod_date | date_to_xmlschema }}</lastmod>