Using liquid to sort posts alphabetically

后端 未结 7 1259
借酒劲吻你
借酒劲吻你 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:17

    I wanted to add following for future reference.

    To sort posts by title, you can use sort filter. See http://jekyllrb.com/docs/templates/#filters

    So, this works:

    {% assign sorted_threat_posts = site.categories.threat | sort: 'title', 'last' %}
    {% for post in sorted_threat_posts %}
       <li><a href="{{ post.url }}">{{ post.title }}</a></li>
    {% endfor %}
    
    0 讨论(0)
提交回复
热议问题