Developers · Liquid
Liquid Tags Introduction
Last updated 1 November 2026
What Liquid tags do, the kinds of tag, and a live example.
Tags are the logic of a template. They are written between {% and %} and print nothing themselves. Use them to assign variables, make decisions, repeat content, run GraphQL and render partials.
Example
insites-cli exec liquid docs57 "{% assign user = 'Adam' %}{% if user %}Hello {{ user }}!{% endif %}"
Hello Adam!This ran on the docs.insites.io instance on 1 November 2026. The assign and if tags print nothing; only the text inside the if appears.
The kinds of tag
| Kind | Examples | Page |
|---|---|---|
| Flow control | if, unless, case | Flow control |
| Loops | for, break, continue | Loops |
| Variables | assign, capture | Variables |
| Include | render, include | Include |
| Theme | liquid, echo | Theme |
| Insites | graphql, redirect_to, log, background | Insites tags |
Many tags in one block
The liquid tag lets you write several tags without repeating the delimiters, one tag per line:
{% liquid
assign name = 'Adam'
if name
echo 'Hello ' | append: name
endif
%}Tags only Insites has
Some tags exist only on Insites, because they talk to the instance. graphql runs a query or mutation and stores the result in a variable. redirect_to sends the visitor to another address. log writes a value to the instance log, which you follow with insites-cli logs. background runs a partial as a background job, so slow work does not hold up the page.
Add a hyphen inside the delimiters, as in {%- if -%}, to remove the spaces and line breaks around a tag. See Whitespace control.
Common mistakes
- Expecting a variable set inside an
includeto come back to the caller. Usefunctionandreturnto get a value back. - Putting two tags on one line inside a
liquidblock. Each tag needs its own line. - Using the
formtag. Use a plain HTML form with the CSRF token.