Configuring order of collection items: PR ready


#1

I asked several months ago for an addition to Jekyll core that would enable users to specify the order of collection items via _config.yml. A volunteer prepared a PR (see https://github.com/jekyll/jekyll/pull/5904) and I’d be grateful if someone could let us know whether it’s likely to be merged some time soon.

Use case: we are using GitHub Pages to build lessons for Software Carpentry and other groups. The lesson sections are in a collection; to order them, we currently have to use naming (like 01-intro.md, 02-basics.md, etc.), but this makes it painful to re-order things (multiple filenames need to change, internal links need to be altered, etc.). Setting the order in _config.yml, and having the previous/next links set up to respect this order automatically, would make life a lot easier.

Constraint: we want to be able to render on GitHub, which means we can’t use plugins, which means we need this in core.

Thanks,
Greg


#2

You can easily achieve this without modification of the Jekyll core. You can get all items/pages and sort by your front matter variable. Then you can detect the current index number by comparing the page.url with the index URL and set a custom nextpage variable using an incremented index. Is there a reason not to use this method?

I can show you an example of this solution if you like (or check my Github account).


#3

Yes, but that’s O(N**2) in the number of pages (since you have to do a linear search for each page). With dozens of short lessons, the build time is slow; with hundreds, it’s impossible.


#4

I think these are your solutions:

  1. Get your PR accepted
  2. Use incremental builds
  3. Try Hugo