Control flow

Control flow

Control flow tags can change the information Liquid shows using programming logic.

if

Executes a block of code only if a certain condition is true.

Input

{% if product.title == 'Awesome Shoes' %}
  These shoes are awesome!
{% endif %}

Output

These shoes are awesome!

unless

The opposite of if – executes a block of code only if a certain condition is not met.

Input

{% unless product.title == 'Awesome Shoes' %}
  These shoes are not awesome.
{% endunless %}

Output

These shoes are not awesome.

This would be the equivalent of doing the following:

{% if product.title != 'Awesome Shoes' %}
  These shoes are not awesome.
{% endif %}<