Build Your Course The Easy Way
Get Started Free

Types

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

In this article:


Strings

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

{% assign var = "Hello, World." %} <h1>{{ var }}</h1>

Numbers

Numbers include floats and integers.

{% assign lucky_number = 18 %} <p>My lucky number is {{ lucky_number }}.</p>

Booleans

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

{% if awesome = true %} <p>Awesome!</p> {% endif %}

Nil

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.

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

{% if post.downloads %} {% include 'downloads' %} {% endif %}

Arrays

Arrays hold a list of variables of all types.

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

{% for tag in blog_post.tags %} <p>{{ tag }}</p> {% endfor %} You can use square brackets ( [ ] ) notation to access a specific item in an array. Array indexing starts at zero.

<p>{{ blog_post.tags[1] }}</p>

Contact support or access our 24/7 Live Chat:

Contact Support Live Chat

Need Help? Live Chat with Us.