Explaining Tags in Pelican

Right after I had celebrated the first anniversary of this blog with the post on my Pelican setup, I decided to write another plugin I've been planning to write for a while: taginfo.py.

Nachtrag (2022-10-07)

Don't take it from here; rather, see https://codeberg.org/AnselmF/pelican-ext

This is for:

Blog screenshot

that is, including explanations in on pages for tags, telling people what the tag is supposed to mean.

To use taginfo, put the file into your plugins folder, add taginfo to the PLUGINS list in your pelicanconf.py, and then create a folder taginfo next to your content folder. In there, for each tag you want to comment, create a file <tagname>.rstx (or just rst). Such a file has to contain reStructuredText, where pelican's extensions (e.g., {filename} links) do not work (yet). I suppose it wouldn't be hard to support them; if you're interested in this plugin, feel free to poke me in case you'd like to see the extra pelican markup.

To make the descriptions visible, you need to change your tag.html template (typically in theme/templates/tag.html) in order to arrange for tag.make_description() to be callsed when rendering the document. Me, I'm doing it like this:

{% block content_title %}
<h1>Tag <em>{{ tag }}</em></h1>
<div id="taginfo">
        {{ tag.make_description() }}
</div>
{% endblock %}

(And I still find jinja templates exceptionally ugly).

Zitiert in: Blog Extensions on Codeberg

Kategorie: edv

Letzte Ergänzungen