Here's a quick (and dirty?) trick to create a tag cloud in Pelican without plugins and minimal amount of code.
Define a jinja filter in pelicanconf.py
to convert a tag's article count
to a CSS font-size
value. For example like this:
import math
JINJA_FILTERS = {
'count_to_font_size': lambda c: '{p:.1f}%'.format(p=100 + 25 * math.log(c, 2)),
}
(Play with the parameters of that mathematical expression to tweak the size mapping to your liking.)
In the tags.html
template you can now use this filter to inject
the font sizes as inline CSS.
For example, in a typical implementation that renders the tags listing
as an item list:
<ul class="tags">
{%- for tag, articles in tags|sort %}
<li style="font-size: {{ articles|count|count_to_font_size }};">
<a href="{{ SITEURL }}/{{ tag.url }}">{{ tag }}</a>
For a pretty tag cloud, you may also need some CSS rules on the corresponding list elements (if not already), in essence something like this:
ul.tags { list-style-type: none; }
ul.tags li { display: inline-block; }
and probably some more margin and padding tweaking.