Jekyll display posts by category

前端 未结 6 637
遇见更好的自我
遇见更好的自我 2020-12-07 09:28

scratching my head over this - help much appreciated.

I want to display a list of all my Jekyll posts, organised by category. I know Line 3 isn\'t correct but I can

6条回答
  •  感动是毒
    2020-12-07 09:54

    Here's an answer that uses sorting (useful!):

    {% comment %}
    #
    #  Change date order by adding '| reversed'
    #  To sort by title or other variables use {% assign sorted_posts = category[1] | sort: 'title' %}
    #
    {% endcomment %}
    {% assign sorted_cats = site.categories | sort %}
    {% for category in sorted_cats %}
    {% assign sorted_posts = category[1] | reversed %}
    

    {{category[0] | capitalize}}

    {% endfor %}

    This is not mine, it's taken from here.

提交回复
热议问题