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.
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:
With that infrastructure in place, outputting articles in the correct order should work for your code without modifications.
To workaround the problem, you can disable categories and pages from being displayed automatically and set the menuitems manually in the configuration:
DISPLAY_CATEGORIES_ON_MENU = False
DISPLAY_PAGES_ON_MENU = False
MENUITEMS = (
('Home', '/'),
('Archives', '/archives.html'),
('Tags', '/tags.html'),
('Category1', 'category/category1.html'),
('Category2', 'category/category2.html'),
)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With