How can I control the order of pages from within a pelican article category?

后端 未结 5 916
余生分开走
余生分开走 2021-01-12 14:28

I am using pelican jinja2 templates in order to generate a navigation menu based on the category and I need a way to control the order of the pages, or at least a trick to a

5条回答
  •  暖寄归人
    2021-01-12 14:48

    You can get sorting using Pelican's custom page metadata and Jinja2's built-in sort filter.

    Example template:

    {% for pg in PAGES|sort(attribute='sortorder') %}
        {{ pg.title }}
  • {% endfor %}

    Example page metadata:

    title: User's Manual
    date: 2014-06-11 15:11
    sortorder: 20
    

提交回复
热议问题