Skip to documentation content

Objects Overview

Objects Overview

Overview of Liquid objects: types, usage with output and methods, and where to find reference.

Objects contain and control all dynamic information used while processing a page. An object may be output directly with {{ object_name }} syntax, modified with filters, or used by methods to control behavior and output. There are numerous object types, each with their own properties and characteristics.

Some objects display nothing when output directly, while others display a specific property, a JSON string of multiple properties, a fully-rendered sub-template, or another predefined string. Refer to each object type's documentation for its default output. More complicated types include page, request, entity, list, dictionary, date, and custom fields.

Properties may be accessed with object.property or object['property'] in most cases; some objects (such as request.query_params and request.cookies) require the bracket form. For more on creating and scoping variables, see Variables Overview.
Example Working with specific object propertiesThere are multiple ways to reference properties on most objects. This example demonstrates several patterns for accessing properties on a few different object types.

Reference properties on the user object

Liquid
{%- if user.is_valid -%}
	{%- if user.custom_property_name -%}
		<p>Custom Property: {{user.custom_property_name}}</p>
	{%- endif -%}
	{%- if user['custom_property_name_2'] -%}
		<p>Custom Property 2: {{user['custom_property_name_2']}}</p>
	{%- endif -%}
{%- endif -%}

Reference properties on the client object

Liquid
{%- if client.is_valid -%}
	{%- if client.custom_property_name -%}
		<p>Custom Property: {{client.custom_property_name}}</p>
	{%- endif -%}
	{%- if client['custom_property_name_2'] -%}
		<p>Custom Property 2: {{client['custom_property_name_2']}}</p>
	{%- endif -%}
{%- endif -%}

Reference properties on the session object

Liquid
{%- if session.is_valid -%}
	{%- if session.custom_property_name -%}
		<p>Custom Property: {{session.custom_property_name}}</p>
	{%- endif -%}
	{%- if session['custom_property_name_2'] -%}
		<p>Custom Property 2: {{session['custom_property_name_2']}}</p>
	{%- endif -%}
{%- endif -%}

Reference custom fields on the site object

Liquid
{%- if site.custom_property_name -%}
	<p>Custom Property: {{site.custom_property_name}}</p>
{%- endif -%}
{%- if site['custom_property_name_2'] -%}
	<p>Custom Property 2: {{site['custom_property_name_2']}}</p>
{%- endif -%}