Reference

Handles

The handle is used to access the attributes of a Liquid object. By default, it is the object’s title in lowercase with any spaces and special characters replaced by hyphens (-). Every object in Liquid (product, collection, blog, menu) has a handle.
Learn more

What is a handle?

The handle is used to access the attributes of a Liquid object. By default, it is the object’s title in lowercase with any spaces and special characters replaced by hyphens (-). Every object in Liquid (product, collection, blog, menu) has a handle.
Learn more

<!-- the content of the About Us page -->
{{ pages.about-us.content }}

How are my handles created?

A product with the title ‘shirt’ will automatically be given the handle shirt. If there is already a product with the handle ‘shirt’, the handle will auto-increment. In other words, all ‘shirt’ products created after the first one will receive the handle shirt-1, shirt-2, and so on.
Learn more

Operators

Liquid has access to all of the logical and comparison operators. These can be used in tags such as if and unless.
Learn more

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

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

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.
Learn more

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 tag or a tablerow tag.
Learn more

{% for tag in product.tags %}
{{ tag }}
{% endfor %}

EmptyDrop

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 a handle.
Learn more

Truthy and Falsy

In programming, we describe “truthy” and “falsy” as anything that returns true or false, respectively, when used inside an if statement.
Learn more

What is truthy?

All values in Liquid are truthy, with the exception of nil and false. In this example, the variable is a string type but it evaluates as true.
Learn more

The only values that are falsy in Liquid are nil and false. nil is returned when a Liquid object doesn’t have anything to return. For example, if a collection doesn’t have a collection image, collection.image will be set to nil.
Learn more

Whitespace Control

In Liquid, you can include a hyphen in your tag syntax {{-, -}}, {%-, and -%} to strip whitespace from the left or right side of a rendered tag.
Normally, even if it doesn’t output text, any line of Liquid in your template will still output an empty line in your rendered HTML.
Learn more

Whitespace Control

Using hyphens, the assign statement doesn't output a blank line.
Learn more

{%- assign my_variable = "tomato" -%}
{{ my_variable }}

tomato

Control Flow Tags

Control Flow Tags determine which block of code should be executed.
Learn more

{% if %}

Executes a block of code only if a certain condition is met.
Learn more

Theme Tags

Theme Tags have various functions including: outputting template-specific HTML markup, telling the theme which layout and snippets to use, and splitting a returned array into multiple pages.
Learn more

{% comment %}

Allows you to leave un-rendered code inside a Liquid template. Any text within the opening and closing comment blocks will not be output, and any Liquid code within will not be executed.
Learn more

Sets a default value for any variable with no assigned value. Can be used with strings, arrays, and hashes. The default value is returned if the variable resolves to nil or an empty string "". A string containing whitespace characters will not resolve to the default value.
Learn more

var content = "\u003Cp\u003E\u003Cstrong\u003EYou made it! Congratulations on starting your own e-commerce store!\u003C/strong\u003E\u003C/p\u003E\n\u003Cp\u003EThis is your shop\u0026#8217;s \u003Cstrong\u003Efrontpage\u003C/strong\u003E, and it\u0026#8217;s the first thing your customers will see when they arrive. You\u0026#8217;ll be able to organize and style this page however you like.\u003C/p\u003E\n\u003Cp\u003E\u003Cstrong\u003ETo get started adding products to your shop, head over to the \u003Ca href=\"/admin\"\u003EAdmin Area\u003C/a\u003E.\u003C/strong\u003E\u003C/p\u003E\n\u003Cp\u003EEnjoy the software, \u003Cbr /\u003E\nYour Shopify Team.\u003C/p\u003E";

The slice filter returns a substring, starting at the specified index. An optional second parameter can be passed to specify the length of the substring. If no second parameter is given, a substring of one character will be returned.
Learn more

Global Objects

Returns a list of all the products in your store. You can use all_products to access your products with their handles.
Learn more

{{ all_products['fancy-shoes'].title }}

Fancy Shoes

canonical_url

Returns the canonical URL of the current page. A page's canonical URL is the page's default URL without any URL parameters.
For products and variants, the canonical URL is the default product page with no collection or variant selected.
Learn more

{{"canonical_url"=>nil}=>nil}

current_page

current_page returns the number of the page you are on when browsing through paginated content. It can be used outside the paginate block.
Learn more

{{ page_title }} - Page: {{ current_page }}

Summer Collection - Page: 1

linklists

Returns a list of all the menus (link lists) in your store. You can use linklists to access your link lists with their handles.
Learn more

Returns the name of the template used to render the current page, without the .liquid extension.
Learn more

{{ template }}

product

address

The address object contains information entered by a customer in Shopify’s checkout pages. Note that a customer can enter two addresses: billing address or shipping address. When accessing attributes of the address object, you must specify which address you want to target. This is done by using either shipping_address or billing_address before the attribute.
Learn more

address.name

Returns the values of the First Name and Last Name fields of the address.
Learn more

Returns the product type on a /collections/types?q=TYPE collection page. For example, you may be on the automatic Shirts collection, which lists all products of type ‘shirts’ in the store: myshop.shopify.com/collections/types?q=Shirts.
Learn more

{% if collection.current_type %}
We are on an automatic product type collection page. The product type is {{ collection.current_type }}.
{% endif %}

collection.current_vendor

Returns the vendor name on a /collections/vendors?q=VENDOR collection page. For example, you may be on the automatic Shopify collection, which lists all products with vendor ‘shopify’ in the store: myshop.shopify.com/collections/vendors?q=Shopify.
Learn more

{% if collection.current_vendor %}
We are on an automatic vendor collection page. The vendor is {{ collection.current_vendor }}.
{% endif %}

collection.default_sort_by

Returns the sort order of the collection, which is set in the collection pages of the Admin.
Learn more

Returns the URL of the next product in the collection. Returns nil if there is no next product. This output can be used on the product page to output ‘next’ and ‘previous’ links on the product.liquid template.
Learn more

collection.previous_product

Returns the URL of the previous product in the collection. Returns nil if there is no previous product. This output can be used on the product page to output ‘next’ and ‘previous’ links on the product.liquid template.
Learn more

collection.products

Returns all of the products inside a collection. Note that there is a limit of 50 products that can be shown per page. Use the pagination tag to control how many products are shown per page.
Learn more

Returns the name of the custom collection template assigned to the collection, without the collection prefix or the .liquid suffix. Returns nil if a custom template is not assigned to the collection.
Learn more

country_option_tags

country_option_tags creates an <option> tag for each country. An attribute named data-provinces is set for each country, containing JSON-encoded arrays of the country’s respective subregions. If a country does not have any subregions, an empty array is set for its data-provinces attribute. country_option_tags must be wrapped in <select> HTML tags.
Learn more

<select name="country">
{{ country_option_tags }}
</select>

current_tags

Product tags are used to filter a collection to only show products that contain a specific product tag. Similarly, article tags are used to filter a blog to only show products that contain a specific article tag. The current_tags variable is an array that contains all tags that are being used to filter a collection or blog.
Learn more

Inside collection.liquid

Inside collection.liquid, current_tags contains all product tags that are used to filter a collection.
Learn more

Inside blog.liquid

Inside blog.liquid, current_tags contains all article tags that are used to filter the blog.
Learn more

customer_address

The customer_address object contains information of addresses tied to a Customer Account.
Learn more

Returns the title or discount code of the discount. Same as discount.title.
Learn more

discount.amount

Returns the amount of the discount. Use one of the money filters to return the value in a monetary format.
Learn more

{{ discount.amount | money }}

$25

discount.total_amount

Returns the total amount of the discount if it has been applied to multiple line items. Use a money filter to return the value in a monetary format.
Learn more

discount.savings

Returns the amount of the discount’s savings. The negative version of amount. Use one of the money filters to return the value in a monetary format.
Learn more

{{ discount.savings | money }}

$-25

discount.total_savings

Returns the total amount of the discount’s savings if it has been applied to multiple line items. The negative version of total_amount. Use a money filter to return the value in a monetary format.
Learn more

form

The form object is used within the form tag. It contains attributes of its parent form.
Learn more

form.author

Returns the name of the author of the blog article comment. Exclusive to form tags with the article parameter.
Learn more

form.body

Returns the content of the blog article comment. Exclusive to form tags with the article parameter.
Learn more

form.email

Returns the email address of the blog article comment’s author. Exclusive to form tags with the article parameter.
Learn more

form.errors

Returns an array of strings if the form was not submitted successfully. The strings returned depend on which fields of the form were left empty or contained errors.
Learn more

{% for error in form.errors %}
{{ error }}
{% endfor %}

<!-- if the Name field was left empty by the user -->
author

form.posted_successfully?

Returns true if the form was submitted successfully, or false if the form contained errors. All forms but the address form set this property. The address form is always submitted successfully.
Learn more

Returns an array of all line items and their quantity included in the fulfillment. Any line items that have already been fulfilled, or are yet to be fulfilled, will not be included in the array.
Learn more

Returns the id of the line item, which is the same as the id of its variant. The line item id is not unique if a variant has different line item properties. Use line_item.key as a unique identifier instead.
Learn more

Returns the type of the link. The possible values are:collection_link: if the link points to a collectionproduct_link: if the link points to a product pagepage_link: if the link points to a pageblog_link: if the link points to a blogrelative_link: if the link points to the search page, the home page or /collections/allhttp_link: if the link points to an external web page, or a type or vendor collection (e.g. /collections/types?q=Pants)
Learn more

Returns the total number of items that are on the pages previous to the current one. For example, if you are paginating by 5 items per page and are on the third page, paginate.current_offset would return 10 (5 items × 2 pages).
Learn more

paginate.items

Returns the total number of items to be paginated. For example, if you are paginating a collection of 120 products, paginate.items would return 120.
Learn more

paginate.parts

Returns an array of all parts of the pagination. A part is a component used to build the navigation for the pagination.
Learn more

paginate.next

Returns the part variable for the Next link in the pagination navigation.
Learn more

product

Returns true if a product is available for purchase. Returns false if all of the products’ variants inventory_quantity values are zero or less, and their inventory_policy is not set to ‘Allow users to purchase this item, even if it is no longer in stock.’
Learn more

product.collections

Returns an array of all of the collections a product belongs to.
Learn more

Returns the variant object of the first product variant that is available for purchase. In order for a variant to be available, its variant.inventory_quantity must be greater than zero or variant.inventory_policy must be set to continue. A variant with no inventory_policy is considered available.
Learn more

The product.image object has the following attributes:product.image.altproduct.image.attached_to_variant?product.image.idproduct.image.product_idproduct.image.positionproduct.image.srcproduct.image.variantsLearn more

Returns the price of the product. Use one of the money filters to return the value in a monetary format.
Learn more

product.price_max

Returns the highest price of the product. Use one of the money filters to return the value in a monetary format.
Learn more

product.price_min

Returns the lowest price of the product. Use one of the money filters to return the value in a monetary format.
Learn more

product.price_varies

Returns true if the product’s variants have varying prices. Returns false if all of the product’s variants have the same price.
Learn more

product.selected_variant

Returns the variant object of the currently-selected variant if there is a valid ?variant= parameter in the URL. Returns nil if there is not.
Learn more

{{ product.selected_variant.id }}

124746062

product.selected_or_first_available_variant

Returns the variant object of the currently-selected variant if there is a valid ?variant= query parameter in the URL. If there is no selected variant, the first available variant is returned. In order for a variant to be available, its variant.inventory_quantity must be greater than zero or variant.inventory_policy must be set to continue. A variant with no inventory_management is considered available.
Learn more

product.tags

Returns an array of all of the product’s tags. The tags are returned in alphabetical order.
Learn more

{% for tag in product.tags %}
{{ tag }}
{% endfor %}

new
leather
sale
special

product.template_suffix

Returns the name of the custom product template assigned to the product, without the product prefix nor the .liquid suffix. Returns nil if a custom template is not assigned to the product.
Learn more

Returns the timestamp of when the transaction was created. Use the date filter to format the timestamp.
Learn more

transaction.receipt

Returns text with information from the payment gateway about the payment receipt. This includes whether the payment was a test case and an authorization code if one was included in the transaction.
Learn more

transaction.kind

Returns the type of transaction. There are five transaction types:

authorization is the reserving of money that the customer has agreed to pay.

capture is the transfer of the money that was reserved during the authorization stage.

sale is a combination of authorization and capture, performed in one step.

void is the cancellation of a pending authorization or capture.

refund is the partial or full refund of the captured money to the customer.

Returns the name of the payment gateway used for the transaction.
Learn more

{{ transaction.gateway }}

Cash on Delivery (COD)

transaction.payment_details

The payment_details object contains additional properties related to the payment method used in the transaction.credit_card_company returns the name of the company who issued the customer’s credit card.credit_card_number returns the customer’s credit card number. All but the last four digits are redacted.
Learn more

variant

Returns true if the variant is available to be purchased, or false if it is not. In order for a variant to be available, its variant.inventory_quantity must be greater than zero or variant.inventory_policy must be set to continue. A variant with no variant.inventory_management is also considered available.
Learn more

Returns the string continue if the ‘Allow users to purchase this item, even if it is no longer in stock.’ checkbox is checked in the variant options in the Admin. Returns deny if it is unchecked.
Learn more