Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Add the following Liquid snippet to a product template (Sections/product-template.liquid) to show tags on a Shopify product page. The tags will correctly link back to the current product collection with the tag filters applied.
{% if product.tags %}
{% if collection.handle %}
{% assign collection_scope = collection.handle %}
{% else %}
{% assign collection_scope = 'all' %}
{% endif %}
<ul class="product-tags">
<li>Tags: </li>
{% for tag in product.tags %}
{% capture url %}/collections/{{ collection_scope }}/{{ tag | handleize }}{% endcapture %}
<li>{{ tag | link_to: url }}</li>
{% endfor %}
</ul>
<style media="screen">
ul.product-tags {
list-style-type: none;
margin: 0;
padding: 0;
}
ul.product-tags li {
display: inline-block;
font-weight: bold;
text-transform: uppercase;
letter-spacing: 1px;
font-size: 12px;
}
ul.product-tags li a {
text-decoration: none;
}
</style>
{% endif %}
@jonathanmoore

This comment has been minimized.

Copy link
Owner Author

commented Jun 26, 2017

This was written specifically for the District theme however it should work for any Shopify theme.

@ahsonRaza

This comment has been minimized.

Copy link

commented Aug 31, 2018

Hi Jonathan, I have a question as i have been searching this and found nowhere the required answer, can you please help me to find a way to add / assign tag to a product through liquid?
I mean i want to give some specific products some specific tags, as there are thousands of products in a store and doing it manually will take days to add the tags, i want something like this
{% if product.price >1 or <75 %}
{% assign tag="less-than-75" %}
{% else %}
{% assign tag="above" %}
{% endif %}

Please ignore the coding error as i am totally new to the shopify liquid
Thanks in advance
Any help will be appreciated

@jinesh24

This comment has been minimized.

Copy link

commented Nov 10, 2018

Hi Jonathan, I have a question as i have been searching this and found nowhere the required answer, can you please help me to find a way to add / assign tag to a product through liquid?
I mean i want to give some specific products some specific tags, as there are thousands of products in a store and doing it manually will take days to add the tags, i want something like this
{% if product.price >1 or <75 %}
{% assign tag="less-than-75" %}
{% else %}
{% assign tag="above" %}
{% endif %}

Please ignore the coding error as i am totally new to the shopify liquid
Thanks in advance
Any help will be appreciated

I think this free app will save hours of your time
https://apps.shopify.com/power-tools-bulk-edit-tags

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.