Understand Liquid operators

Liquid has access to all common logical and comparison operators. These can be used in tags such as if and unless.

Basic operators

== Equals
!= Does not equal
> Greater than
< Less than
>= Greater than or equal to
<= Less than or equal to
Or Condition A or condition B
And Condition A and condition B

contains

contains tests for the presence of a substring within a string.

{% if page.title contains 'Product' %}

The title of this page contains the word Product.

{% endif %}

contains can also test for the presence of a string within an array of strings.

startswith

startswith tests whether a string starts with a given substring.

{% if page.title startswith 'Profile' %}

This is a profile page.

{% endif %}

endswith

endswith tests whether a string ends with a given substring.

{% if page.title endswith 'Forum' %}

This is a forum page.

{% endif %}

See also

Add dynamic content and create custom templates
Store source content by using web templates
Liquid types
Conditional
Liquid Objects
Liquid Tags
Liquid Filters
Create advanced templates for portals