What do you need help with?

We are here and ready to help.


Liquid objects can return one of six types: String, Number, Boolean, Nil, Array, or EmptyDrop. Liquid variables can be initialized by using the assign or capture tags.


Strings are declared by wrapping the variable's value in single or double quotes.

{% assign my_string = "Hello World!" %}



Numbers include floats and integers.

{% assign my_num = 25 %}



Booleans are either true or false. No quotations are necessary when declaring a boolean.

{% assign foo = true %}
{% assign bar = false %}



Nil is an empty value that is returned when Liquid code has no results. It is not a string with the characters "nil".

Nil is treated as false in the conditions of {% if %} blocks and other Liquid tags that check for the truthfulness of a statement. The example below shows a situation where a fulfillment does not yet have a tracking number entered. The if statement would not render the included text within it.

{% if fulfillment.tracking_numbers %}
We have a tracking number!
{% endif %}

Any tags or outputs that return nil will not show anything on the screen.


Tracking number: {{ fulfillment.tracking_numbers }}


Tracking number: 


Arrays hold a list of variables of all types.

Accessing all items in an array

To access items in an array, you can loop through each item in the array using a for tag or a tablerow tag.


<!-- if product.tags = "sale", "summer", "spring", "wholesale" -->
{% for tag in product.tags %}
 {{ tag }}
{% endfor %}


sale summer spring wholesale

Accessing a specific item in an array

You can use square brackets ( [ ] ) notation to access a specific item in an array. Array indexing starts at zero.


<!-- if product.tags = "sale", "summer", "spring", "wholesale" -->
{{ product.tags[0] }} 
{{ product.tags[1] }} 
{{ product.tags[2] }} 
{{ product.tags[3] }} 



Initializing an array

It is not possible to initialize an array in Liquid. For example, in Javascript you could do something like this:

var cars = ["Saab", "Volvo", "BMW"];

In Liquid, you must instead use the split filter to break a single string into an array of substrings. See here for examples.


An EmptyDrop object is returned whenever you try to access a non-existent object (for example, a collection, page or blog that was deleted or hidden) by handle. In the example below, page_1page_2 and page_3are all EmptyDrop objects.

{% assign variable = "hello" %}
{% assign page_1 = pages[variable] %}
{% assign page_2 = pages["i-do-not-exist-in-your-store"] %}
{% assign page_3 = pages.this-handle-does-not-belong-to-any-page %}

EmptyDrop objects only have one attribute, empty?, which is always true.

Collections and pages that do exist do not have an empty? attribute. Their empty? is “falsy”, which means that calling it inside an if statement will return false. When using an unless statement on existing collections and pages, empty? will return true.

Applications in themes

Using the empty? attribute, you can check to see if a page exists or not before accessing any of its other attributes.

{% unless pages.frontpage.empty? %}
 <!-- We have a page with handle 'frontpage' and it's not hidden.-->
 <h1>{{ pages.frontpage.title }}</h1>
 <div>{{ pages.frontpage.content }}</div>
{% endunless %}

It is important to see if a page exists or not first to avoid outputting empty HTML elements to the page, as follows:


You can perform the same verification with collections as well:

{% unless collections.frontpage.empty? %}
 {% for product in collections.frontpage.products %}
 {% include 'product-grid-item' %}
 {% else %}
 <p>We do have a 'frontpage' collection but it's empty.</p>
 {% endfor %}
{% endunless %}
Facebook Share Tweet

Was this article helpfu?

Yes No

Thank you for voting

Select company

You are related to multiple companies. Please select the company you wish to login as.