Search code examples
htmlyamljekyllgithub-pages

Manually order a Jekyll collection


As mentioned in the Jekyll docs here, I have the following in my _config.yml as:

collections:
  sections:
    order:
      - introduction.md
      - battery-state.md
      - vibe.md
      - references.md

To render the content of each file within the HTML, I have the following:

{% for section in site.sections %}
  {{ section.content }}
{% endfor %}

However, the content order is not presented as what I defined in the config file. How do I display the content in the order I defined in the config file?


Solution

  • Manually ordering documents in a collection was introduced in Jekyll 4.0 To use this feature, make sure that you're using Jekyll 4.0

    For a site deployed on GitHub Pages, that would mean having to build the site outside GitHub Pages environment and upload the contents of the destination directory (_site).