Sort_by slug / path

My use-case is pretty straightforward and seems quite common to me. I have a number of pages and sections that start with a number prefix e.g., 00_post.md, 01_post.md, etc., and I’d like to have them sorted by this prefix. They don’t have this number in a title, so sorting by title is not an option. The only way is to sort by weight, which requires adding it to every single page.

The default sorting (none) seems to sort entities in random order, which makes no sense to me.

I can add a new sorting order: sort_by = slug or path, whichever seems more reasonable to you.

Let me know what you think, so I can start working on it.

+1 for this feature request. I’m working on a project with hundreds of files that begin with a number, and need to be processed in ascending order. At present I have to add a sequential weight into every .md file which is hugely inefficient. Being able to sort on filename would be a god send, and I imagine very useful for other similar use-cases.

Hi, @matthillco ! This is already implemented and should be available in the latest Zola release

@bemyak Oh cool, that sounds great! Looks like it’s still in the next branch though and not released yet. Sorting by slug in 0.16.1 generates an unknown variant error. I can’t wait to try this out in the next release, it will save me a ton of time! Thank you for proposing and working on this fix. :+1:

Incidentally, will this still work if I’m using path overrides in my meta data? I’m working with sequential numbered files, but need to hard-code their final deployment paths to end up in different locations. Will my setup work with sorting by slug in this case?