Tags

Tags are markup for programming logic within Live Editor themes.

Tag markup does not output anything but allows you to code logic into your templates. Tags are surrounded by matched pairs of curly brackets and percent signs:

      {% unless page_title == 'Home' %}
        {{ page_title }}
      {% endunless %}

Tags can be broken down into 4 categories:

  1. Base tags
  2. Control flow tags
  3. Iteration tags
  4. Layout tags
  5. Variable tags

Base tags

There are a few tags available for meeting basic programming needs like commenting, escaping, and including templates.

comment
Omit blocks of text and code from being output.
include
Inserts and executes an include file from the includes/ folder of the theme.
raw
Allows you to escape Liquid markup within a template.

Control flow tags

Control Flow tags determine which block of code should be executed based on different conditions.

if, elsif, and else
Only execute code if a certain condition is met.
unless
The inverse of if: only execute code if a certain condition is not met.
case, when, and else
Creates a switch statement looking for the first when match for the value passed to case.

Iteration tags

Iteration tags allow you to loop through a collection of values and execute code for each item.

for, break, and continue
Allows you to iterate over an array and execute code for each item in the array.
cycle
Accepts a list of strings as parameters and cycles through each one and outputs it.

Layout tags

Layout tags provide hooks and settings for layout functionality like editable regions and navigation menus.

navigation
Allows you to indicate where in a layout to place the markup for a navigation menu.
region
Defines where to place editable regions within a layout.

Variable tags

Use these tags to create new variables in your Liquid templates.

assign
Creates a new variable.
capture
Captures the string inside of the opening and closing tags and assigns it to a variable.
increment
Creates a new number variable, increases its value by 1 every time it is called, and outputs it.
decrement
Creates a new number variable, decreases its value by 1 every time it is called, and outputs it.

Next steps

Continue your deep dive into Liquid with the Object Reference.