Using liquid to sort posts alphabetically

后端 未结 7 1396
借酒劲吻你
借酒劲吻你 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 20:11

    According to the documentation, to filter an array by one of its field, you can use :

        {% assign sortedPosts = site.posts | sort: 'title' %}
    

    Then the sortedPosts variable will contain the sorted array.

    The documentation can be found here : https://docs.shopify.com/themes/liquid/filters/array-filters#sort

提交回复
热议问题