Skip to content

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

KindExamplesPage
Flow controlif, unless, caseFlow control
Loopsfor, break, continueLoops
Variablesassign, captureVariables
Includerender, includeInclude
Themeliquid, echoTheme
Insitesgraphql, redirect_to, log, backgroundInsites 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 include to come back to the caller. Use function and return to get a value back.
  • Putting two tags on one line inside a liquid block. Each tag needs its own line.
  • Using the form tag. Use a plain HTML form with the CSRF token.