Shopify Categories Within Collections
How to use Liquid to create product navigation in Shopify
Shopify doesn’t have categories so to speak, but it does have collections and tag and you can combine them to make powerful and intuitive product navigation.
<ul class="collections"> {% for collection in collections %}
{% if collection.handle != 'frontpage' %}
<li><h3><a href="{{ collection.url }}" title="{{ collection.title }}">{{ collection.title }}</a></h3>
<ul class="tags"> {% for tag in collection.all_tags %}
<li><a href="{{ collection.url }}/{{ tag | handleize }}" title="{{ tag | escape }}">{{ tag }}</a></li>
{% endfor %}
</ul>
</li>
{% endif %}
{% endfor %}
</ul>
The above code will create a product navigation of all your collections and all the tags within the appropriate collection. The third line of code is use to exclude collection such as the frontpage collection which isn’t really appropriate in your product navigation.
Great bit of code!
Did not think of this:
{% if collection.handle != ‘frontpage’ %}
very useful
Thanks 🙂