Available Liquid conditional operators

When used in conditional statements (if,unless), some Liquid values will be treated as true, and some will be treated as false.

In Liquid, null and the Boolean value false are treated as false;everything else is treated as true. Empty strings, empty arrays, etc. are treated as true. For examples,

{% assign empty_string =  %}
{% if empty_string %}
<p>This will render.</p>
{% endif %}

You can test for empty strings and arrays using the special value empty if necessary.

{% unless page.title == empty %}
<h1>{{ page.title }}</h1>
{% endunless %}

You can also test the size of Liquid types, Liquid types, or Liquid types using the special size property.

{% if page.children.size > 0 %}
{% for child in page.children %}
<li>{{ child.title }}</li>
{% endfor %}
{% endif %}


True False
True ×
False ×
Null ×
String ×
empty string ×
0 ×
1, 3.14 ×
array or dictionary ×
empty array or dictionary ×
Object ×

See also

Store source content by using web templates
Understand Liquid operators
Liquid types
Liquid Objects
Liquid Tags
Liquid Filters