I host my blog on github and wanted to find a solution to sort the tag list that does not involve any jekyll plugins, since Github does not allow plugins to be configured (jekyll bootstrap also tries this). My post here does not answer the question, since I am sorting by tag name, NOT by size. You can adapt this method to output the tag size as well as a string, and then execute some fancier splitting function to get a different sort order (but it will be messy).
I was able to do this with the following code:
{% capture tagString %}{% for tag in site.tags %}{{ tag[0] }}{% unless forloop.last %}|{% endunless %}{% endfor %}{% endcapture %} {% assign tags = tagString | split: '|' | sort: 'downcase' %} <div id="cloud"> {% for tag in tags %} {% assign number = site.tags[tag].size %} {% assign slug = tag | downcase | replace: ' ', '_' %} <span class="{% if number == 1 %}small{% elsif number <= 5 %}medium{% elsif number <= 10 %}large{% else %}huge{% endif %}"> <a href="#tag-{{ slug }}">{{ tag | downcase }}</a> </span> {% endfor %} </div>
This is odd as I commit the tag string (using | as a separator) and then use it to create an array. After this point (in a loop) I can refer to the tag as a tag and a list of sites that use this tag as site.tags[tag] .
I use this on my blog: https://github.com/kelsin/kelsin.imtqy.com/blob/master/tags/index.html
The rest of the code is how I selected the tag cloud on my tag page. Hope this helps someone else looking for a solution (without plugins)!
source share