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

jinja2, pelican, python

Solution

Pelican 3.5 will introduce built-in support for article and page ordering. You can define in your pelicanconf.py by which metadata attribute articles and pages should be sorted. The two variables are:

ARTICLE_ORDER_BY = 'attribute'
PAGE_ORDER_BY = 'attribute'

For this to work correctly, you must ensure that:

- every page / article defines the specified attribute, otherwise you will get a compiler error saying the page / article class doesn't have this attribute

- your attribute always uses the same number of character; so the values 1, 10 and 100 won't produce a correct order, but 001, 010 and 100 will do

With that infrastructure in place, outputting articles in the correct order should work for your code without modifications.

Problem

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 allow me to choose the first page to be listed. ``` {% for a in articles %} {% if a.category == category %} <li><a href="{{ SITEURL }}/{{ a.slug }}">{{ a.title }} {% endif %} {% endfor %} ``` How can a make one specific article page to be the first. Their sourse is in markdown format.

Original source