Types
Liquid output can be one of six data types.
string
Any series of characters, wrapped in single or double quotes.
TipYou can check whether a string is empty with the
blankobject.
number
Numeric values, including floats and integers.
boolean
A binary value, either true or false.
nil
An undefined value.
Tags or outputs that return nil don't print anything to the page. They are also treated as false.
NoteA string with the characters “nil” is not treated the same as
nil.
array
A list of variables of any type.
To access all of the items in an array, you can loop through each item in the array using a for or tablerow tag.
You can use square bracket [ ] notation to access a specific item in an array. Array indexing starts at zero.
You can’t initialize arrays using only Liquid. You can, however, use the split filter to break a single string into an array of substrings.
empty
An empty object is returned if you try to access an object that is defined, but has no value. For example a page or product that’s been deleted, or a setting with no value.
You can compare an object with empty to check whether an object exists before you access any of its attributes.
{% assign contact_us_page_id = '333653' %}
{% unless pages[contact_us_page_id] == empty %}
<h1>{{ page.title }}</h1>
<div>{{ page.content }}</div>
{% endunless %}{
"page": {
"title": "Contact us",
"content": "Some content...",
}
}<h1>Contact us</h1>
<div>Some content...</div>Updated about 1 month ago
