current_tags

Product tags are used to filter a collection to only show products that contain a specific product tag. Similarly, article tags are used to filter a blog to only show products that contain a specific article tag. The current_tags variable is an array that contains all tags that are being used to filter a collection or blog.

📘

Tip

Tags inside the current_tags array will always display in alphabetical order. It is not possible to manually change the order.

Inside collection.liquid

Inside collection.liquid, current_tags contains all product tags that are used to filter a collection.

The example below creates a list that displays every tag within every product in a collection. If the collection is filtered by the tag (i.e. if current_tags does contain the tag), the link will remove the filter. If the collection is not currently filtered by the tag (if current_tags does not contain the tag), a link will appear to allow the user to do so.

<ul>
{% for tag in collection.all_tags %}
    {% if current_tags contains tag %}
          <li class="active">{{ tag | link_to_remove_tag: tag }}</li>
    {% else %}
          <li>{{ tag | link_to_add_tag: tag }}</li>
    {% endif %}
{% endfor %}
</ul>