I'm trying to display the current year in my footer in Pelican website. My understanding is that Pelican uses Jinja2 template.
In my footer.html I use:
<span>{{ now().year }}</span>
And I use it in my base.html as
{% include 'footer.html' %}
But when I generate the page I've got the error
Undefined Error: 'now' is undefined
And I cannot find the reason.
Is there any trick/setting/plugin I need to use this?
Pelican provides a
strftimeextra filter to Jinja, that works exactly like Python'sstrftime.Here are the sources of this finding:
This said, you will need a
datetimeobject to use this filter on.The later can be obtained by modifying your configuration file, pelicanconf.py, adding those two lines
Now, in your template, you can start using this newly created
NOWvariable and apply thestrftimeformat, which means that you want%Yfor the year: