Using liquid to sort posts alphabetically

后端 未结 7 1391
借酒劲吻你
借酒劲吻你 2021-02-01 19:45

Is there a way to sort a number of posts alphabetically, using Jekyll?

I have something like this now:

{% for post in site.categories.threat %}


        
7条回答
  •  名媛妹妹
    2021-02-01 19:58

    It's both clean and elegant to sort in Jekyll in GitHub pages without a plugin. Use your .yml data file in the _data directory. I use a data file here called team-members.yml:

    {% assign sorted_team = site.data.team-members | sort:'title' %}
    {% for member in sorted_team %}
        {{ member.title }}
    {% endfor %}
    

    This pattern will handle what you need to do here.

提交回复
热议问题