When a non-Boolean data type is used in a Boolean context (for example in a conditional tag), Liquid decides whether it counts as true or false. Values that count as true are called truthy. Values that count as false are called falsy.

Truthy

All values in Liquid are truthy except nil and false.

In this example, the text "Tobi" is not a Boolean, but it is truthy in a condition:

{% assign name = "Tobi" %}

{% if name %}
  This text is always shown when "name" is defined.
{% endif %}

Empty strings are truthy. The following example outputs empty HTML tags if settings.fp_heading exists but is empty:

{% if settings.fp_heading %}
  <h1>{{ settings.fp_heading }}</h1>
{% endif %}
<h1></h1>

To avoid this, check whether the string is blank:

{% unless settings.fp_heading == blank %}
    <h1>{{ settings.fp_heading }}</h1>
{% endunless %}

An EmptyDrop is truthy as well. In the following example, you get an EmptyDrop if settings.page is an empty string or points to a hidden or deleted object. The result is an unwanted empty <div>.

Input:

{% if pages[settings.page] %}

 <div>
  {{ pages[settings.page].content }}
 </div>
{% endif %}

Output:

 <div></div>

Falsy

The only falsy values in Liquid are nil and false.

nil is returned when a Liquid object has nothing to return. For example, if a collection has no image, collection.image is nil. Because that is falsy, you can write:

{% if collection.image %}

 <!-- output collection image -->
{% endif %}

The value false is returned by many object properties, for example product.available.