Shopify Categories Within Collections

How to use Liquid to create product navigation in Shopify

collection-categoriesShopify 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.

Share this:
  • Digg
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • Design Float
  • Reddit
  • StumbleUpon
  • Twitter
  • Design Bump
This entry was posted in Tutorials. Bookmark the permalink. Post a comment or leave a trackback: Trackback URL.

One Comment

  1. Posted April 28, 2010 at 3:46 am | Permalink

    Great bit of code!

    Did not think of this:

    {% if collection.handle != ‘frontpage’ %}

    very useful

    Thanks :-)

Post a Comment

Your email is never published nor shared. Required fields are marked *

*
*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Subscribe without commenting

  • ecommerce done right Advertise with us Advertise with us Advertise with us