Tags
Liquid tags are used to define the logic that tells templates what to do.
Conditional tags
Conditional tags define conditions that determine whether blocks of Liquid code get executed.
Iteration tags
Iteration tags repeatedly run blocks of code.
Theme tags
Theme tags assign or render content that’s part of your theme.
Variable tags
Variable tags enable you to create new Liquid variables.
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