Search code examples
pythonpelican

How to sort articles by filename in pelican?


In Pelican 3.5 I know I can sort articles by attributes, like

ARTICLE_ORDER_BY = 'title'

but I would like to order by the filename. It is much easier to change the filenames than to open each file and edit the attributes.


Solution

  • Try this:

    ARTICLE_ORDER_BY = 'filename'
    

    or

    ARTICLE_ORDER_BY = lambda x:os.path.basename(x.source_path or '')