Logical and comparison operators

Liquid supports basic logical and comparison operators for use with conditional tags.

!=does not equals
>greater than
<less than
>=greater than or equal to
<=less than or equal to
orCondition A or Condition B
andCondition A and Condition B
containsChecks for strings in strings or arrays


You can use contains to check for the presence of a string within an array, or another string. You can’t use contains to check for an object in an array of objects.

{% if product.tags contains 'hot' %}
  This potion contains hot properties.
{% endif %}
  "product": {
    "tags": [
This potion contains hot properties.

Order of operations

When using more than one operator in a tag, the operators are evaluated from left to right, and you can’t change this order.



Parentheses () aren’t valid characters within Liquid tags. If you try to include them to group operators, then your tag won’t be rendered.

{% unless true and false and false or true %}
  This evaluates to true, since Liquid checks tags like this:
  ((true and false) and false) or true
  (false and false) or true
  false or true
{% endunless %}
<!-- empty -->