jekyll: List of collections not rendering

I am trying to build a list of the collections I have defined in my _config.yml, thus:

collections:
  articles:
    output: true
    title: Articles
  essays:
    output: true
    title: Academic Essays
  presentations:
    output: true
    title: Presentations
  projects:
    output: true
    title: Projects

using the following Liquid template:

{% for collection in site.collections %}
    <section>
        <h1><a href="{{ collection.directory }}">{{ collection.title }}</a></h1>
        Label: {{ collection.label }}
    </section>
{% endfor %}

but the following is rendered:

<section>
    <h1><a href=""></a></h1>
    Label: 
</section>
<section>
    <h1><a href=""></a></h1>
    Label: 
</section>
<section>
    <h1><a href=""></a></h1>
    Label: 
</section>
<section>
    <h1><a href=""></a></h1>
    Label: 
</section>

The documentation says:

…collections are also available under site.collections, with the metadata you specified in your _config.yml

Is what I’m attempting correct? Or is this a bug?

Thanks—and congratulations on shipping v2!

About this issue

  • Original URL
  • State: closed
  • Created 10 years ago
  • Comments: 35 (20 by maintainers)

Commits related to this issue

Most upvoted comments

just commenting that @FloFra’s method doesn’t seem to be working anymore. To get a similar behaviour, I now used:

{% for collection in site.collections %}
{% unless collection.label == 'posts' %}
<h2>{{collection.label}}</h2>
<ul>
    {% for file in collection.files %}
    <li><a href="{{ file.path | remove: "_" }}">{{ file.path | remove: "_" }}</a></li>
    {% endfor %}
</ul>
{% endunless %}
{% endfor %}