How can I hide tags from filters in the Dawn Theme?

Topic summary

Goal: Hide specific product tags (e.g., those with an underscore like _onetimetrue) from Dawn theme filters.

Key fix on desktop/no‑JS lists (facets.liquid):

  • Use the correct loop variable: change “values” to “value”.
  • Inside each “{%- for value in filter.values -%}” loop, add:
    • “{% assign tag_value = value.value %}”
    • Wrap the list item markup with “{% unless tag_value contains ‘_’ %} … {% endunless %}”.
  • Apply this in both rendered and no‑JS lists within the section.

Mobile drawer update required:

  • In the mobile filters section, inside “{%- for value in filter.values -%}”, add the same “assign” and “unless … contains ‘_’” check. Close each “unless”. This hides the tags on mobile as well.

Common pitfalls and errors:

  • Placing “assign/unless” outside the value loop causes Liquid errors and breaks logic (e.g., “Unknown tag ‘when’”). Ensure the check wraps only the list item inside the loop.
  • If tags still appear, verify you’re checking value.value and not the rendered label HTML.

Outcome: Users report success on desktop and mobile once the checks are added in the correct locations. One user resolved issues by moving the code to the proper place. The thread appears resolved.

Summarized with AI on December 30. AI used: gpt-5.

I tried at first to use the code as presented in this post, but I had to also assign tag_value to get it to work. The important bits are:
{% assign tag_value = value.value %}

{% unless tag_value contains ‘_’ %}

Add those two pieces after both instances of “{%- for value in filter.values -%}” inside the section.

Here’s the section of code I changed in facets.liquid, with the additions shown in blue. The bits between are just notes to document what the additions are doing; those won’t show in the generated page and don’t affect function, they’re purely informational.

{{ filter.label | escape }}
    {%- for value in filter.values -%}

    {% assign tag_value = value.value %}
    {% unless tag_value contains ‘_’ %}

  • <svg
    width=“1.6rem”
    height=“1.6rem”
    viewBox=“0 0 16 16”
    aria-hidden=“true”
    focusable=“false”


    <svg
    aria-hidden=“true”
    class=“icon icon-checkmark”
    width=“1.1rem”
    height=“0.7rem”
    viewBox=“0 0 11 7”
    fill=“none”
    xmlns=“http://www.w3.org/2000/svg


    {{ value.label | escape }} ({{ value.count }})

    {{- value.label | escape }} (
    {%- if value.count == 1 -%}
    {{- ‘products.facets.product_count_simple.one’ | t: count: value.count -}}
    {%- else -%}
    {{- ‘products.facets.product_count_simple.other’ | t: count: value.count -}}
    {%- endif -%}
    )</span

  • {% endunless %} {%- endfor -%}
{% comment %} No show more for no JS {% endcomment %}
    {%- for value in filter.values -%}

    {% assign tag_value = value.value %}
    {% unless tag_value contains ‘_’ %}

  • <svg
    width=“1.6rem”
    height=“1.6rem”
    viewBox=“0 0 16 16”
    aria-hidden=“true”
    focusable=“false”


    <svg
    aria-hidden=“true”
    class=“icon icon-checkmark”
    width=“1.1rem”
    height=“0.7rem”
    viewBox=“0 0 11 7”
    fill=“none”
    xmlns=“http://www.w3.org/2000/svg


    {{ value.label | escape }} ({{ value.count }})

    {{- value.label | escape }} (
    {%- if value.count == 1 -%}
    {{- ‘products.facets.product_count_simple.one’ | t: count: value.count -}}
    {%- else -%}
    {{- ‘products.facets.product_count_simple.other’ | t: count: value.count -}}
    {%- endif -%}
    )</span

  • {% endunless %} {%- endfor -%}
1 Like