---
title: "Tags"
slug: "liquid-tags-tags"
updated: 2026-03-24T13:29:21Z
published: 2026-03-24T13:29:21Z
canonical: "academy.insiderone.com/liquid-tags-tags"
---

> ## Documentation Index
> Fetch the complete documentation index at: https://academy.insiderone.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Tags

Tags are the structural and logical building blocks of a Liquid template. Denoted by {% %} delimiters, they govern control flow, iteration, and variable assignment, but unlike output blocks, they render no content to the page themselves.

## if / elsif / else / endif

```plaintext
{% if condition %}
  ...
{% elsif other_condition %}
  ...
{% else %}
  ...
{% endif %}
```

Every if must be closed with {% endif %}.

```plaintext
{% if c_loyalty_tier == "gold" %}
  Gold member offer: free shipping on all orders.
{% elsif c_loyalty_tier == "silver" %}
  Silver member offer: free shipping over 500 TL.
{% else %}
  Standard shipping rates apply.
{% endif %}
```

## unless

The opposite of if. It runs when the condition is false.

```plaintext
{% unless c_loyalty_tier == blank %}
  Welcome back, {{ c_loyalty_tier }} member!
{% endunless %}
```

This is equivalent to {% if c_loyalty_tier != blank %}. You cannot use elsif with unless.

## case / when

You can match a single value against multiple options.

```plaintext
{% case c_loyalty_tier %}
  {% when "bronze" %}
    Welcome to our loyalty program!
  {% when "silver" %}
    Welcome, Silver member!
  {% when "gold" %}
    Welcome, Gold member — your exclusive benefits are active.
  {% else %}
    Join our loyalty program to start earning rewards.
{% endcase %}
```

You can match multiple values in one when using commas.

```plaintext
{% case language %}
  {% when "tr", "az" %}
    Merhaba!
  {% when "en", "au", "nz" %}
    Hello!
  {% else %}
    Hi!
{% endcase %}
```

The or keyword is not supported inside when. You can use commas instead.

## for

You can loop over a list or a number range.

```plaintext
{% for item in items %}
  {{ item }}
{% endfor %}
```

**Number range**

```plaintext
{% for i in (1..5) %}
  {{ i }}
{% endfor %}
→  1 2 3 4 5
```

**limit****,** **offset****,** **reversed**

```plaintext
{% for item in items limit: 3 %}...{% endfor %}
{% for item in items offset: 2 %}...{% endfor %}
{% for item in items limit: 3 offset: 2 %}...{% endfor %}
{% for item in items reversed %}...{% endfor %}
```

**break** **and** **continue**

```plaintext
{% for item in items %}
  {% if item == "skip_me" %}{% continue %}{% endif %}
  {% if item == "stop_here" %}{% break %}{% endif %}
  {{ item }}
{% endfor %}
```

### forloop variables

| Variable | Description |
| --- | --- |
| forloop.index | Current position, starting from **1** |
| forloop.index0 | Current position, starting from **0** |
| forloop.first | *true* on the first iteration |
| forloop.last | *true* on the last iteration |
| forloop.length | Total number of iterations |

```plaintext
{% for item in items %}
  {% if forloop.first %}<ul>{% endif %}
  <li>{{ forloop.index }}. {{ item }}</li>
  {% if forloop.last %}</ul>{% endif %}
{% endfor %}
```

## assign

You can create a variable or store a computed value.

```plaintext
{% assign greeting = "Hello" %}
{% assign full_name = name | append: " " | append: surname %}
{% assign price_with_tax = c_last_order_amount | times: 1.18 %}
```

Variables created with assign persist for the rest of the template, including after loops.

## capture

You can capture a block of rendered content into a variable.

```plaintext
{% capture order_summary %}
  <b>{{ name }}</b> — {{ c_loyalty_tier | upcase }} member
{% endcapture %}

{{ order_summary }}
```

It is useful for building strings that are reused in multiple places, or for constructing a subject line.

```plaintext
{% capture subject %}
  {% if c_loyalty_tier == "gold" %}
    Your exclusive Gold offer is ready, {{ name }}
  {% else %}
    A special offer just for you, {{ name | default: "there" }}
  {% endif %}
{% endcapture %}

Subject: {{ subject | strip }}
```

## increment / decrement

They are auto-counting variables, independent from assign.

increment starts at 0 and counts up.

```plaintext
{% increment counter %}   →  0
{% increment counter %}   →  1
{% increment counter %}   →  2
```

decrement starts at -1 and counts down.

```plaintext
{% decrement counter %}   →  -1
{% decrement counter %}   →  -2
{% decrement counter %}   →  -3
```

increment / decrement are entirely independent from assign. Using the same name for both does not cause a conflict, they maintain separate values.

```plaintext
{% assign x = 10 %}
{% increment x %}    →  0    (not 10)
{{ x }}              →  10   (assign variable unchanged)
```

## comment

Everything inside is ignored and not rendered.

```plaintext
{% comment %}
  This will not appear in the output.
  {{ variables }} here are not processed either.
{% endcomment %}
```

## raw

You can disable template processing for a block.

```plaintext
{% raw %}
  Use {{ variable }} and {% tag %} syntax in your templates.
{% endraw %}
```
