You need to update your articles time and again. Sometimes it makes sense to display the date when you updated the article.

Pelican release v3.4.0 has a new metadata field modified. Type of its value is datetime.

You can show the last updated date of the article by defining modified in your article metadata.

This is how it is displayed in the side bar,

Modified Date

Depending on your DATE_FORMATS setting you can put modified date in your reST formatted file as

:modified: 2014-01-22 14:30

Elegant will process it and display the last updated as “Jan 22, 2014”.

Condition to Display Last Updated

Last Updated is only displayed if the difference between article.modifed and article.dateis more than or equal to a day.

This means if you modify and article the same day you add it, then Last Updated will not be displayed.

Tip

You may want to enable filetime_from_git Pelican plugin to auto fill the modified field for your Git commit history.

Deprecated

Warning: Legacy Variable

Pelican versions prior to 3.4 does not have modified metadata in which case type of its value is string.

If you are using old version of Pelican, i.e 3.3 or less, make sure you assign it a value exactly the way you want it to appear. Whatever you type, it will appear as it is.

Taking the example from above, metadata in your reST formatted file should be,

:modified: Jan 22, 2014

You can also assign raw HTML to it. For example,

:modified: <a href="https://github.com/talha131/onCrashReboot/" title="Revision History">Aug 29, 2013</a>

But I do not recommend it because it will break on newer versions of Pelican. In fact, you should ditch Pelican 3.3 or less and move to a higher version if you require modified metadata.

Понравилась статья? Расскажите о ней на: TwitterFacebookEmail


Talha Mansoor is the creator and lead developer of Elegant theme

Что почитать


Дата

Категория

Advanced Features

Тэги

Будьте с нами