Skip to main content

highlight_active_tag

string | highlight_active_tag
returns string

Wraps a given tag within the collection object in an HTML <span> tag, with a class attribute of active, if the tag is currently active. Only applies to collection tags.

{% for tag in collection.all_tags %}
{{- tag | highlight_active_tag | link_to_tag: tag }}
{% endfor %}

Output

<a href="/services/liquid_rendering/extra-potent" title="Show products matching tag extra-potent"><span class="active">extra-potent</span></a>

<a href="/services/liquid_rendering/fresh" title="Show products matching tag fresh">fresh</a>

<a href="/services/liquid_rendering/healing" title="Show products matching tag healing">healing</a>

<a href="/services/liquid_rendering/ingredients" title="Show products matching tag ingredients">ingredients</a>
Was this page helpful?