Display Elements in site.categories and site.tags of My Jekyll Blog Website

Jul. 13, 2024

Display elements in site.categories elements

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
{% assign categories_max = 0 %}
{% for category in site.categories %}
 {% if category[1].size > categories_max %}
  {% assign categories_max = category[1].size %}
 {% endif %}
{% endfor %}

<ol>
{% for i in (1..categories_max) reversed %}
 {% for category in site.categories %}
  {% if category[1].size == i %}
  	<li>{{ category[0] }} ({{ i }})</li>
  {% endif %}
 {% endfor %}
{% endfor %}
</ol>


Display elements in site.tags elements

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
{% assign tags_max = 0 %}
{% for tag in site.tags %}
  {% if tag[1].size > tags_max %}
    {% assign tags_max = tag[1].size %}
  {% endif %}
{% endfor %}

<ol>
  {% for i in (1..tags_max) reversed %}
    {% for tag in site.tags %}
      {% if tag[1].size == i %}
      	<li> {{ tag[0] }} ({{ i }}) </li>
      {% endif %}
    {% endfor %}
  {% endfor %}
</ol>


References