Search code examples
pythonhtmlpelicanstatic-site

Using PAGE_ORDER_BY = 'page-order' in Pelican HTML pages


Using Pelican, the python static site generator, I want to re-order how my pages display in the navigation.

My pages are html, not markdown/ reST.

According to the docs & How can I control the order of pages from within a pelican article category? I should be using: PAGE_ORDER_BY = 'page-order'

In the pelicanconf.py.

I have tried the following meta tags in my html pages, and used the same number format in each page: ='000' ='111' etc.

<meta page-order="888">
<meta name="page-order" content="888">

I get the following error when compiling the site: There is no "page-order" attribute in the item metadata. Defaulting to slug order.

What is the correct method of specifying page order in HTML pages?

Thanks in advance.


Solution

  • Solved this by following this structure:

    in config (no hyphen):

    PAGE_ORDER_BY = 'sortorder'
    

    HTML Page Structure:

    {% extends "base.html" %}
    <html>
    <head>
        <title>Test</title>
        <meta name="sortorder" content="222" />
    </head>
    <body>
    </body>
    </html>
    

    Pelican removes the html/head/body and uses the ones included in your base html, but seems to need this structure to recognise the meta tags in the head. Make sure to use the same number of digits in each content="", eg. 111, 222, 333 not 1, 222, 33.