Code for displaying product tags on product pages

Topic summary

A user is implementing code to display product tags on product pages for internal linking purposes. They have working code that excludes certain tags (like “CAZAAR” and “not-on-sale”) from being displayed to customers.

Two issues identified:

  • Tag spacing problem: When a tag contains a space (e.g., “pre order”), the current code only displays the first part (“pre”) instead of the full tag.

  • Brand tag filtering: The user wants to exclude all tags starting with “BRAND_” (e.g., “BRAND_”) from display. They found code to filter by prefix but couldn’t get it to work properly, possibly due to incorrect placement.

The discussion remains open with no solutions provided yet for either formatting issue.

Summarized with AI on November 17. AI used: claude-sonnet-4-5-20250929.

Hi,

I am trying to add product tags to the actual product pages to increase internal links.
I do use a lot of tags in conjunction with other apps that I dont want customers to see.

I currently have (found) the following code which I have tested as working -

{% assign exclude_tags = “CAZAAR,not-on-sale” | split: ‘,’ %}

tags:

{% for tag in product.tags %}

{% if exclude_tags contains tag %}

{% continue %}

{% endif %}

{{ tag | handleize }}{% unless forloop.last %}{% endunless %}

{% endfor %}

This ensures CAZAAR & not-on-sale tags dont show.
Every product also has a tag starting with BRAND_, is there anyway I can stop all of these tags showing but just stating the start, i.e. all tags starting with BRAND_ should not display.

I found this code, but I couldnt get it to work (maybe I was placing it in the code above incorrectly?)

{% assign prefix = tag | slice: 0 %}

{% if prefix == ‘BRAND’ %}

{% continue %}

{% endif %}

Lastly, I have noticed with the first code above, if a tag has a space like - ‘pre order’ as an example, this would just show the tag ‘pre’ - is there any way to fix this?

Many thanks

Mike