I'm using the static site generator Pelican. I've configured the ARTICLE_URL
setting to include the year and month in the url.
For example with
ARTICLE_URL = 'posts/{date:%Y}/{date:%b}/{slug}/'
My post url will be something like
/posts/2015/Dec/my-new-post/
I would prefer the month to be lowecase, i.e.
/posts/2015/dec/my-new-post/
Is there an easy way to achieve this?
I was facing the same problem and solved it by making a small Pelican plugin that adds the lower case month name as a content metadata variable.
Here is the plugin:
from pelican import signals
def add_lowercase_month_to_metadata(content):
if "date" in content.metadata:
content.metadata["lowercase_month"] = content.metadata["date"].strftime("%B").lower()
content.metadata["lowercase_month_short"] = content.metadata["date"].strftime("%b").lower()
def register():
signals.content_object_init.connect(add_lowercase_month_to_metadata)
Once it's activated you can use the new lowercase month name variables (lowercase_month
and lowercase_month_short
) in the ARTICLE_URL
and ARTICLE_SAVE_AS
:
ARTICLE_URL = '/{date:%Y}/{lowercase_month_short}/{date:%d}/{slug}'
ARTICLE_SAVE_AS = '{date:%Y}/{lowercase_month_short}/{date:%d}/{slug}/index.html'