Filtering collections by tags in liquid

Shopify Partner
16 0 0

I am aware that you can filter a collection by appending tags in the url but is there are way to do this purely in liquid. If I have a collection object for example, is there a way to retrieve only the products that contain certain tags without looping through the entire collection? 

I realize this is probably not possible so if that's the case a simple "not possible" will suffice. Thanks in advance!

Shopify Staff (Retired)
Shopify Staff (Retired)
965 1 51

Hey Chris!

As far as I know, I don't believe this is possible, but it might be worth reaching out on the API and technology forum to see what they say over there. I'm really uncertain if there's a way to do so without looping in the entire collection.

You can find the API and technology forum through the link below:


Let me know what you think!

Matthew Buttler
Shopify Inc.

Shopify Partner
205 0 24

What about just not showing the products containing the tag:

{% for product in collections['my-collection-handle'].products %}
  {% unless product.tags contains "display" %}
    {{ product }}
  {% endundless %}
{% endfor %}


Shopify Partner
13 0 2

I'm trying to do something similar, and the method @hj suggested works BUT it doesn't play nicely with pagination. I was hoping something like the following would work:

{% paginate collection.products unless product.title contains 'wholesale' by 8 %}

Although it would actually probably need to be a filter and there's no syntax that makes any sense that I can think of for a filter...