Jekyll & Liquid: Output category list with post count?

前端 未结 3 1846
逝去的感伤
逝去的感伤 2021-02-01 07:42

I\'m somehow stuck and don\'t find the right way to do it.

I want to output a category list with the number of posts in each categorie.

I got this far: https://p

3条回答
  •  自闭症患者
    2021-02-01 08:17

    I have written a code snippet that not only shows post count in each category, but also navigates to the posts of a specific category which got clicked. I hope you find it helpful:

    
    
    {% for tag in site.categories %} 
      

    {{ tag[0] | capitalize }}

      {% assign pages_list = tag[1] %} {% for post in pages_list %} {% if post.title != null %} {% if group == null or group == post.group %}
    • {{ post.title }}
    • {% endif %} {% endif %} {% endfor %} {% assign pages_list = nil %} {% assign group = nil %}
    {% endfor %}

提交回复
热议问题