Get name of each post in each category

You are the best!

Going to mark this as a solution, as that covers basically every question I came up with on this journey and more. (collection.docs … that is beautiful, and after as much digging should have been more obvious)

The rabbit I was ultimately looking to pull out of the hat was to change this:

{% for collection in site.collections %}
  {% assign name = collection.label %}
    <h1>{{ name }}</h1>
    {% for page in site.name %}
        <p>foo</p>
        <p>{{ page.title }}</p>
    {% endfor %}
{% endfor %}

to this:

{% for dir in site.collections %}
  {% assign collection = dir.label %}
    <h1>{{ collection }}</h1>
    {% for page in site[collection] %}
        <a href="{{ site.baseurl }}{{ page.url }}">{{ page.title }}</a>
    {% endfor %}
{% endfor %}

I’m not super familiar with liquid (er, obvs) and am not seeing, on either the Shopify or Github docs the difference between “.” and “[ ]” (In fact in my quick-like skim through I didn’t see any references to “[]”'s at all)

So, why does that work?

And thanks a million Michael, I found the band site stumbling through other answers here. Super helpful.

1 Like