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 false are treated as false, everything else is treated as true. Empty strings, empty arrays, etc. are treated as true.

{% 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 strings, arrays, or dictionaries using the special size property.

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

Summary

TrueFalse
true ×
false ×
null ×
string ×
empty string ×
0 ×
1, 3.14 ×
array or dictionary ×
empty array or dictionary ×
object ×