collections
All of the collections on a store.
Directly accessible in
- Global
Anchor to Iterate over the collections
Iterate over the collections
You can iterate over collections
to build a collection list.
{% for collection in collections %}
{{- collection.title | link_to: collection.url }}
{% endfor %}
{% for collection in collections %}
{{- collection.title | link_to: collection.url }}
{% endfor %}
Output
<a href="/collections/empty" title="">Empty</a>
<a href="/collections/featured-potions" title="">Featured potions</a>
<a href="/collections/freebies" title="">Freebies</a>
<a href="/collections/frontpage" title="">Home page</a>
<a href="/collections/ingredients" title="">Ingredients</a>
<a href="/collections/potions" title="">Potions</a>
<a href="/collections/sale-potions" title="">Sale potions</a>
Anchor to Access a specific collection
Access a specific collection
You can use collections
to access a collection by its handle.
{% for product in collections['sale-potions'].products %}
{{- product.title | link_to: product.url }}
{% endfor %}
{% for product in collections['sale-potions'].products %}
{{- product.title | link_to: product.url }}
{% endfor %}
Output
<a href="/products/draught-of-immortality" title="">Draught of Immortality</a>
<a href="/products/glacier-ice" title="">Glacier ice</a>
<a href="/products/health-potion" title="">Health potion</a>
<a href="/products/invisibility-potion" title="">Invisibility potion</a>
Was this section helpful?