I am using Pelican 3.3 and I have an almost static file index.html
in my jinja2 templates. I would like to display the date of the last modification of the file within it.
I found quite easily that article.locale_date
and page.locale_date
are doing the job for articles and pages (with DEFAULT_DATE = 'fs'
). But, I cannot figure out how to do this for a template file.
I found some suggestions about using a Python function through other Python modules such as Flask
or Environment
. But, is there a simpler way to get the date of last modification of a template file ?
I found a dirty trick, so I still hope that somebody will answer this question in a more nicer way than I did.
The point is to use the
pelicanconf.py
file to set up an environment variable to get the required date. I just added the following topelicanconf.py
:Once you get the
INDEX_DATE
variable set, you can use it in your Jinja2 templates like this:So, this is a quick and dirty trick. Hopefully, somebody will give me a better way !