Sort order of Jekyll Collections
Somewhat annoyingly, Jekyll’s default list of collections is in alphabetical order of collection name.
So if your _config.yml specifies
collections:
moose_and_goose_stories:
title: The Moose and Goose Stories
grey_parrot_stories:
title: The Grey Parrot Stories
predicting_the_present:
title: Predicting the Present
and you process the collections using the default ordering
it will give you
- The Grey Parrot Stories
- The Moose and Goose Stories
- Predicting the Present
based on the g-m-p of the collection names, i.e. not the far more intuitive order of how they are listed in the _config.yml.
This is my workaround - adding a sequence attribute to each collection
collections:
moose_and_goose_stories:
title: The Moose and Goose Stories
sequence: 1
grey_parrot_stories:
title: The Grey Parrot Stories
sequence: 2
predicting_the_present:
title: Predicting the Present
sequence: 3
and modifying the processing to sort by sequence
(NB the use of an assign statement to set up the variable value, since you can’t do it directly in the for statement.)
to give you
- The Moose and Goose Stories
- The Grey Parrot Stories
- Predicting the Present
...
<<PREV NEXT>>
...
...
Sort order of Jekyll Collections
(from Jekyll Notes)
by Chris Gathercole
http://stories.upthebuzzard.com, RSS
published: 19 February 2017
...
This work is licensed under a
Creative Commons, ATTRIBUTION-NONCOMMERCIAL-SHAREALIKE 4.0 INTERNATIONAL License (CC BY-NC-SA 4.0).
...
mashup (... er, what?)
...
Credits
Sort order of Jekyll Collections
(from Jekyll Notes)
by Chris Gathercole
http://stories.upthebuzzard.com, RSS
published: 19 February 2017
...
This work is licensed under a
Creative Commons, ATTRIBUTION-NONCOMMERCIAL-SHAREALIKE 4.0 INTERNATIONAL License (CC BY-NC-SA 4.0).
...
mashup (... er, what?)
...
Credits
Background image from Wikipedia