• EQUAL (==)

    The EQUAL operator == is used to evaluate whether something is true.

    Input
    {% assign color = "blue" -%}
    {% if color == 'Blue' -%}
      <p>The color is Blue.</p>
    {% endif -%}
    Output
    The color is Blue.
  • DOES NOT EQUAL (!=)

    The DOES NOT EQUAL operator != is used to evaluate whether something is false (or not equal to the other).

    Input
    {% if red != 'Blue' -%}
    <p>The color is not Blue.</p>
    {% endif -%}
    Output
    The color is not Blue.
  • GREATER THAN (>)

    The GREATER THAN > is used to evaluate whether something is greater than the compared value.

    Input
    {% if 10 > 4 -%}
    <p>10 is greater than 4</p>
    {% endif -%}
    Output
    10 is greater than 4
  • LESS THAN (<)

    The LESS THAN < is used to evaluate whether something is less than the compared value.

    Input
    {% if 4 < 10 -%}
    <p>4 is less than 10</p>
    {% endif -%}
    Output
    4 is less than 10
  • GREATER THAN OR EQUAL TO (>=)

    The GREATER THAN OR EQUAL TO >= is used to evaluate whether something is greater than or equal to the compared value.

    Input
    {% if 10 >= 10 -%}
    <p>10 is greater than or equal to 10</p>
    {% endif -%}
    Output
    10 is greater than or equal to 10
  • LESS THAN OR EQUAL TO (<=)

    The LESS THAN OR EQUAL TO <= is used to evaluate whether something is less than or equal to the compared value.

    Input
    {% if 4 <= 10 -%}
    <p>4 is less than or equal to 10</p>
    {% endif -%}
    Output
    4 is less than or equal to 10

 


Misc Operators

In tags with more than one AND or OR operator, the operators are checked from right to left. You cannot change the order of operations using parentheses as parentheses are invalid characters in Liquid and will prevent your tags from rendering.

  • OR

    The OR decision operator renders true if one or both of the evaluated values is true.

    Input
    {% if blue == 'blue' or 'red' -%}
    <p>The color is Blue or Red.</p>
    {% else -%}
    <p>The color is Green.</p>
    {% endif -%}
    Output
    The color is Blue or Red.
  • AND

    Decision operators that renders true if both of the evaluated values is true.

    Input
    {% if {{itemColor}} == 'Blue' and {{itemSize}} == 'large' -%}
    <p>The shirt is Blue and size Large.</p>
    {% else -%}
    <p>The shirt is out of stock.</p>
    {% endif -%}
    Output
    The shirt is Blue and size Large.
  • CONTAINS

    You can use CONTAINS to check whether a string contains another string.

    CONTAINS can only search string values. You cannot use it to check for an object in an array of objects.

    Input
    {% if {{itemColor}} contains 'Blue' -%}
    <p>The color is Blue.</p>
    {% else -%}
    <p>Blue shirts are out of stock.</p>
    {% endif -%}
    Output
    The color is Blue.