AI answers drawn only from these docs, with links to the pages used.

Liquid Types

Last updated on October 15, 2026

This document details the following topics:

  • String
  • Boolean
  • Number
  • Nil
  • Hash (Object)
  • Array
  • Empty
  • Truthy and Falsy values

String

Declare a string by wrapping a variable's value in single or double quotes:

A backslash escapes the next character in a string. Put a backslash before a quote to use a quote of the same kind inside a string, for example . Write two backslashes for one backslash. Any other backslash, such as d in a pattern, stays as written.

Boolean

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

Number

Numbers include floats and integers:

Nil

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

Nil is treated as in the conditions of if blocks and other Liquid tags that check the truthfulness of a statement.

In the following example, if the user does not exist (that is, the user returns nil), Liquid will not print the greeting:

Tags or outputs that return nil will not print anything to the page.

Input

Output

Hash (Object)

Hash represents an object as a key value dictionary, allowing a value to be another Hash. The most used hash is context, a built-in global object.

Initializing a new object

To create a hash, assign a hash literal. As in JSON, keys are written in double quotes, a key can also be a variable, and literals can be nested. You can also start from an empty hash and set keys with dot or bracket notation:

The parse_json tag and filter are deprecated for JSON you write in the template. Use parse_json only to turn a JSON string that arrives at runtime, such as an API response, into a hash: .

Accessing object attributes

To access a value of an object, you can use dot notation or bracket [] notation if you would like to use variables instead of a hardcoded key.

Input

Output

Array

Arrays hold lists of variables of any type.

Accessing Items in Arrays

You can loop through each item using an iteration tag to access all the items in an array.

Input

Output

Accessing Specific Items in an Array

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

Input

Output

Initializing Arrays

Create an array with an array literal. Items can be numbers, strings or variables, and [] is an empty array. Append to an existing array with <<, for example .

The split filter turns a string into an array of strings.

Searching in Arrays

These are the two methods you can use to search arrays

contains

You can check for the presence of a substring in a string, but can also check for the presence of a string in an array of strings. You can use it only for searching strings. You cannot use it to check for an object in an array of objects.

array_any

Parameters:

  • array (Array) - array to search in - default: []
  • query (StringNumber) - String/Number compared to each item in the given array - default: 'true'

Empty

An object is returned if you try to access an object that is defined but has no value. For example, a page or product deleted or a setting with no value.

You can compare an object with to check whether an object exists before you access any of its attributes.

Truthy and Falsy Values

In programming, anything that returns true in a conditional (return true by default) is called truthy. Anything that returns false in a conditional (return false by default) is called falsy. All object types can be described as either truthy or falsy.

Truthy

All values in Liquid are truthy except nil and false.

In the example below, the string 'Tobi' is not a boolean, but it is truthy in a conditional:

Strings, even when empty, are truthy. The example below will result in empty HTML tags if is empty.

Input

Output

Falsy

The falsy values in Liquid are nil and false.

Truthy and Falsy Summary Table

ValueTruthyFalsy
true
false
nil
string
empty string
0
integer
float
array
empty array
page
Empty Drop
Have a suggestion for this page?

Didn't quite find what you are looking for or have feedback on how we can make the content better then we would love to hear from you. Please provide us feedback and we will get back to you shortly.