Control flow tags
Control flow tags create conditions that decide whether blocks of Liquid code get executed.
Executes a block of code only if a certain condition is met (that is, if the result is
if, but executes a block of code only if a certain condition is not met (that is, if the result is
The above example is the same as:
else / elsifAnchor link to section titled "else / elsif"
Adds more conditions to an
case / whenAnchor link to section titled "case / when"
Creates a switch statement to execute a particular block of code when a variable has a specified value.
case initializes the switch statement, and
when statements define the various conditions.
You can optionally add an
else statement at the end of the case to provide code to execute if none of the conditions are met.
Multiple conditions (and / or)Anchor link to section titled "Multiple conditions (and / or)"
You can use the
or operators to include more than one condition in a control flow tag.
or can be chained together to create complex conditionals. To learn about the order in which these operators are checked, refer to the Operators reference.
and operator lets you add additional conditions to a tag. A condition with an
and will only be true if both the left and the right side of the condition are true.
or operator lets you add additional conditions to a tag. A condition with an
or will be true if either the left or the right side of the condition is true.