Liquid tags are used to define the logic that tells templates what to do.

Usage

Tags are wrapped with curly brace percentage delimiters {% %}. The text within the delimiters doesn't produce visible output when rendered.

In the example below, the if tag defines the condition to be met. If product.available returns true, then the price is displayed. Otherwise, the “sold-out” message is shown.

{% if product.available %}
	Price: $12.88
{% else %}
	Sorry, this product is sold out.
{% endif %}
{
  "product": {
    "available": true
  }
}
Price: $12.88

Tags with parameters

Certain tags accept parameters. Some tags have required parameters, and others are optional. For example, the for tag can accept parameters like limit to exit a loop at a specific index.

{% assign numbers = '1,2,3,4,5' | split: ',' %}

{% for item in numbers limit: 2 %}
  {{ item }}
{% endfor %}
1
2