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

{% for collection in site.collections %}
  {% if collection.title %}
* {{ collection.title | escape }}
  {% endif %}
{% endfor %}

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.)

{% assign collections = (site.collections | sort: 'sequence') %}
{% for collection in site.collections %}
  {% if collection.title %}
* {{ collection.title | escape }}
  {% endif %}
{% endfor %}

to give you

  • The Moose and Goose Stories
  • The Grey Parrot Stories
  • Predicting the Present

Other posts