Truthy and falsy

All data types must return either true or false. Those which return true by default are called truthy. Those that return false by default are called falsy.

ValueTruthyFalsy
true
false
nil
empty string
0
integer
float
array
empty array
page
empty object

Example

Because nil and false are the only falsy values, you need to be careful how you check values in Liquid. A value might not be in the format you expect, but still be truthy.

For example, empty strings are truthy, so you need to check whether they're empty with blank. EmptyDrop objects are also truthy, so you need to check whether the object you're referencing is empty.

{% if settings.heading_font_family != blank %}
  {{ settings.heading_font_family }}
{% else %}
  No value for this setting has been selected.
{% endif %}

{% assign recipes_page_id = '3366359' %}
{% unless pages[recipes_page_id] == empty %}
  {{ page[recipes_page_id].content }}
{% else %}
  No page with this handle exists.
{% endunless %}
{
  "settings": {
    "heading_font_family": null
  }
}
No value for this setting has been selected.
No page with this handle exists.