--- url: https://developer.youcan.shop/themes/tags/ifchanged.md --- # `ifchanged` Outputs its content only when the content is different from the last time the tag rendered. Use it inside a [`for`](./for.md) loop to show a value once for each group of items. ```liquid {% ifchanged %} block_to_output {% endifchanged %} ``` * `block_to_output`: Rendered expression when it is different from the previous one. Example: ::: details Data ```json { "products": [ { "title": "Hat", "type": "Caps" }, { "title": "Cap", "type": "Caps" }, { "title": "Tee", "type": "Shirts" } ] } ``` ::: ```liquid {% for product in products -%} {% ifchanged %}

{{ product.type }}

{% endifchanged -%}

{{ product.title }}

{% endfor %} ``` ::: tip Output ```html

Caps

Hat

Cap

Shirts

Tee

``` :::