{% comment %} Creates a tag cloud with tags beeing sized according to the number of occurences in blog posts. {% endcomment %} {% comment %} Create an empty array. {% endcomment %} {% assign tags = "" | split:"" %} {% comment %} Fill the tags-array with tag-names. The push-filter is a Jekyll specific filter. {% endcomment %} {% for tag in site.tags %} {% assign tags = tags | push: tag.first %} {% endfor %} {% comment %} Sort the tag-array case-insensitive. {% endcomment %} {% assign tags_sorted = tags | sort_natural %} {% comment %} Requirements: - The tag with the most posts should always be displayed at 250% - The tag with the fewest posts (this can also be more than 1!) always with 100%. - All gradations in between should be distributed linearly. Determine minimum an maximum value. Assumption: Non of the tags occurs more than one million times. {% endcomment %} {% assign min = 1000000 %} {% assign max = 0 %} {% for tag in tags_sorted %} {% assign postsWithThisTag = site.tags[tag] | size %} {% if postsWithThisTag > max %} {% assign max = postsWithThisTag %} {% endif %} {% if postsWithThisTag < min %} {% assign min = postsWithThisTag %} {% endif %} {% endfor %} {% assign sizeDifference = 150 %} {% assign steps = max | minus: min %}