Shopify Liquid cheat sheet and guide: syntax, tags, filters and objects
Shopify Liquid is the template language Shopify themes use to turn store data into HTML. This page gives you a cheat sheet of its syntax, tags, filters, objects and comments, then the patterns and checks that keep theme code working.

Shopify Liquid in short
Generated by Ecompanda AI
Liquid is the template language Shopify created for themes, and it runs on Shopify's servers before the browser sees the page. You print data with objects in double curly braces, add logic with tags, and change values with filters.
- Objects in {{ }} print data, tags in {% %} add logic, filters after a pipe change a value
- Only nil and false are falsy, so test empty text with blank
- Use render for snippets because include is deprecated
- A for loop stops at 50 items, so use paginate for more
- Run Theme Check before you publish
Shopify Liquid is the template language Shopify created to build themes. Liquid markup lives in .liquid files and runs on Shopify's servers, turning store data into the HTML a shopper sees. It has three building blocks: objects in {{ }} print data, tags in {% %} add logic, and filters after a pipe | change a value.
Below is a cheat sheet you can keep open while you edit. After it come the parts that trip people up: what counts as empty, how snippets see variables, loop limits, and the stricter parser Shopify switched on in January 2026. Every row matches Shopify's own Liquid reference.
Try Shopify free
Open a store, set up your first products and test the ideas in this guide as you read.
Start free trialAffiliate link. We may earn a commission at no cost to you.
Shopify Liquid cheat sheet
The tables cover the syntax people look up most. Each filter below comes with a small working example.
Liquid template syntax
| Syntax | What it does | Example |
|---|---|---|
| {{ }} | Prints a value on the page | {{ product.title }} |
| {% %} | Runs an instruction (a condition, a loop, a render). The tag text itself never shows on the page | {% if product.available %} |
| {%- -%} and {{- -}} | Strips the whitespace on the side that has the hyphen | {%- if cart.item_count > 0 -%} |
| {% liquid %} | Runs many tags in one block, one per line, without delimiters | See the comment example below |
| {% comment %} {% endcomment %} | Block comment. Nothing inside is output | {% comment %} Old banner {% endcomment %} |
| {% # note %} | Inline comment inside a single tag | {% # hide until launch %} |
| {% raw %} {% endraw %} | Shows Liquid code as text instead of running it | {% raw %}{{ product.title }}{% endraw %} |
Liquid tags: logic, loops and variables
| Tag | Use it to | Example |
|---|---|---|
| if, elsif, else | Show something when a condition is true | {% if product.available %} In stock {% endif %} |
| unless | Show something unless a condition is true | {% unless customer %} Log in {% endunless %} |
| case, when | Pick one branch by value | {% case block.type %} {% when 'image' %} |
| for | Repeat for each item, up to 50 | {% for item in cart.items %} |
| limit, offset, reversed | Change how many items a for loop shows, and in what order | {% for p in collection.products limit: 4 %} |
| break, continue | Stop a loop, or skip to the next item | {% break %} |
| paginate | Split a long list across pages | {% paginate collection.products by 24 %} |
| assign | Create a variable | {% assign on_sale = true %} |
| capture | Save rendered output as a string | {% capture heading %}{{ shop.name }} news{% endcapture %} |
| echo | Print a value inside a liquid tag | echo product.title |
| render | Output a snippet with its own scope | {% render 'price', variant: variant %} |
| content_for | Mark where theme blocks appear in a section | {% content_for 'blocks' %} |
| doc | Document the parameters a snippet expects | {% doc %} @param {object} variant {% enddoc %} |
Conditions use ==, !=, >, <, >=, <=, and, or and contains. That's the full list on the basics page. There is no && or ||, and you can't group conditions with parentheses.
Common Liquid filters
upcase,downcase,appendandtruncatechange text:{{ product.title | truncate: 40 }}escapemakes text safe inside HTML:{{ block.settings.title | escape }}moneyandmoney_with_currencyformat a price with the store's currency settings:{{ product.price | money }}defaultgives a fallback when a value is nil, false or empty:{{ product.selected_variant.url | default: product.url }}image_urlandimage_tagget an image at a set size, then build the<img>:{{ product.featured_image | image_url: width: 600 | image_tag }}dateformats a timestamp:{{ article.created_at | date: '%B %d, %Y' }}tprints text from the theme's locale files:{{ 'products.product.add_to_cart' | t }}where,find,rejectandsizework on arrays:{{ collection.products | where: 'vendor', 'Acme' | size }}jsonprints any value as JSON, which is handy while debugging:{{ product.tags | json }}
Shopify objects you will use most
| Object | What it holds | Properties you will reach for |
|---|---|---|
| product | A product in the store | title, price, variants, featured_image, selected_or_first_available_variant |
| variant | One variant of a product | price, compare_at_price, available |
| collection | A collection | title, url, products, products_count |
| cart | The shopper's cart | item_count, items, total_price |
| section | The current section | id, settings, blocks, index |
| block | One block inside a section | type, settings, shopify_attributes |
| settings | Theme settings from settings_schema.json | settings.your_setting_id |
| shop | The store itself | name |
| customer | The logged-in customer, nil when nobody is logged in | first_name |
| request | The current URL and page | page_type, design_mode |
| all_products | Any product, looked up by handle | all_products['handle'], up to 20 unique handles per page |
Each object has its own page under Objects in the reference, with every property and its type.
How do you write a comment in Liquid?
Wrap a block comment in {% comment %} and {% endcomment %}, or write an inline comment as {% # your note %}. Nothing inside a comment is output. Liquid inside a block comment is parsed but not run.
{% comment %}
Old holiday banner. Keep the markup for next year.
{% endcomment %}
{% # show the badge only on sale items %}
{%- liquid
# inside a liquid tag, a comment line starts with #
assign on_sale = false
-%}Two rules catch people out. The comment tag reference says a multi-line inline comment needs a # at the start of every line. And the strict parser guide says a comment inside a liquid tag must sit on its own line, not after code.
What is Shopify Liquid?
Liquid is a template language created by Shopify. The core is an open source project written in Ruby and used by other software too. Shopify's theme version adds the tags, filters and objects that are specific to stores.

A template language lets one file serve many pages. Your product template describes the page once. Liquid then fills in the title, images and price of whichever product the shopper is viewing.
One catch. Shopify runs slightly different versions of Liquid for notification emails, Shopify Flow and order printer templates, and the theme reference does not cover them. So a tag that works in your theme may fail in an email template.
How Shopify turns Liquid into a page
A theme is a set of files that Shopify assembles in layers. The theme architecture page puts it this way: the layout is the base, the template controls what a page shows, sections are modules the template lists, blocks sit inside sections, and snippets are reusable pieces you can render anywhere.

Two details matter when you edit:
layout/theme.liquidmust contain{{ content_for_header }}and{{ content_for_layout }}. The layouts page says that without them you can't save the file in the code editor or Shopify CLI.- A JSON template is data, not code. It lists sections and their order, and it can render up to 25 sections with up to 50 blocks each. A Liquid template holds code.
All of this runs before the browser sees anything. Shopify's performance guide says Liquid renders server-side on every page request, and that time directly sets Time to First Byte. So slow Liquid means a slow page, whatever your images weigh.
Objects, tags and filters in practice
Objects and handles
Objects expose properties with dots. Resources with a handle, such as pages, can also be read with square brackets, which helps when the handle has a hyphen:
<h1>{{ product.title | escape }}</h1>
<p>{{ product.vendor }}</p>
<a href="{{ pages['about-us'].url }}">About us</a>Truthy, falsy and blank
In Liquid only nil and false are falsy. The basics page lists the results:
| Value | Treated as |
|---|---|
| nil (missing value) | falsy |
| false | falsy |
| Empty string | truthy |
| 0 | truthy |
| Empty array | truthy |
So {% if section.settings.heading %} passes when the merchant left the heading empty. Compare with blank instead:
{% if section.settings.heading != blank %}
<h2>{{ section.settings.heading | escape }}</h2>
{% endif %}Operators are evaluated from right to left, and you can't change that order. Parentheses are not valid inside tags. So split a long condition into nested if blocks rather than trying to group it.
Filters
Filters chain from left to right and take arguments after a colon. A few details from the reference:
- Prices are whole numbers. Price fields come out in the currency's subunit, so a price of
1000prints as 10.00 in the store's currency format once it goes through money. image_urlneeds a size. Give it awidthor aheight. An image is never made larger than the original.- Filters have a home. Under the strict parser they only work in output tags,
assignandecho. You can't put one inside arenderargument. Assign the result to a variable first.
Snippets: why render replaced include
A snippet is a reusable file in snippets/. Merchants can't see snippets in the theme editor, so they suit product cards, icons and price blocks.
Call one with render:
{% render 'product-card', product: item, show_price: true %}
{% render 'product-card' for collection.products as product %}The first line passes named values. The second renders the snippet once per item, and as product names the current item inside the snippet. The render reference also documents with for passing a single object.

Scope is the point. A snippet can't read variables you created outside it. It can read global objects and objects that are directly available where it's rendered, such as section inside a section. Variables it creates stay inside it.

The older include tag shared one scope with the page. The include reference marks it deprecated because the way it handles variables "reduces performance and makes code harder to both read and maintain". If your theme still uses it, replace each call and pass the variables the snippet needs.
Document your snippets with LiquidDoc
Shopify announced LiquidDoc on 21 May 2025. A {% doc %} block at the top of a snippet or block file is read by code editors and Theme Check. A missing parameter then shows up as a warning instead of a silent bug. Parameters are written @param {type} name - description, with square brackets around optional ones. Here is snippets/price.liquid:
{% doc %}
Prints the price of one variant, with a struck-through compare-at
price when the variant is on sale.
@param {object} variant - The variant to price
@param {boolean} [show_compare_at] - Set to false to hide the compare-at price
@example
{% render 'price', variant: product.selected_or_first_available_variant %}
{% enddoc %}
{%- liquid
assign on_sale = false
if variant.compare_at_price and variant.compare_at_price > variant.price
assign on_sale = true
endif
-%}
<div class="price{% if on_sale %} price--on-sale{% endif %}">
<span class="price__current">{{ variant.price | money }}</span>
{%- if on_sale and show_compare_at != false -%}
<s class="price__compare">{{ variant.compare_at_price | money }}</s>
{%- endif -%}
</div>
Why price the variant and not the product? Product price fields are the lowest across all variants. On a product page you want the selected one. And compare_at_price is empty when none is set, so the snippet checks it exists before comparing.
Sections and blocks in Liquid
A section file holds markup, a {% schema %} with the settings merchants edit, and presets that let it be added in the theme editor. Inside it, section.settings reads those settings and section.id identifies the instance. Our sections and blocks guide covers the editor side.
Theme blocks live in blocks/ and can be reused across sections. The section marks where they go with content_for 'blocks' and accepts them with @theme in its schema. This is sections/feature-list.liquid:
<section class="feature-list" style="--columns: {{ section.settings.columns }}">
{%- if section.settings.heading != blank -%}
<h2>{{ section.settings.heading | escape }}</h2>
{%- endif -%}
<div class="feature-list__items">
{% content_for 'blocks' %}
</div>
</section>
{% schema %}
{
"name": "Feature list",
"settings": [
{ "type": "text", "id": "heading", "label": "Heading", "default": "Why shop with us" },
{ "type": "range", "id": "columns", "label": "Columns", "min": 1, "max": 4, "step": 1, "default": 3 }
],
"blocks": [{ "type": "@theme" }],
"presets": [{ "name": "Feature list" }]
}
{% endschema %}And the block it accepts, blocks/feature.liquid:
<div class="feature" {{ block.shopify_attributes }}>
<h3>{{ block.settings.title | escape }}</h3>
<p>{{ block.settings.text | escape }}</p>
</div>
{% schema %}
{
"name": "Feature",
"settings": [
{ "type": "text", "id": "title", "label": "Title", "default": "Free returns" },
{ "type": "textarea", "id": "text", "label": "Text" }
],
"presets": [{ "name": "Feature" }]
}
{% endschema %}block.shopify_attributes prints the data attributes the theme editor uses to find a block.
Section blocks are the older style. They're declared in the section's own schema and looped with section.blocks, with a limit of 50 blocks per section. Branch on block.type, never on block.id. The section schema page warns that block IDs are generated and can change.
{%- for block in section.blocks -%}
{%- case block.type -%}
{%- when 'feature' -%}
<div class="feature" {{ block.shopify_attributes }}>
<h3>{{ block.settings.title | escape }}</h3>
</div>
{%- endcase -%}
{%- endfor -%}A static block is placed in code instead of by the merchant: {% content_for 'block', type: 'feature', id: 'trust-badge' %}. See the content_for reference.
Patterns you will use every week
Metafield output
Metafields are read with resource.metafields.namespace.key. You can't create them in Liquid, only in the admin or through an app. Check for a value with blank, then print:
{%- assign ingredients = product.metafields.custom.ingredients -%}
{%- if ingredients != blank -%}
<h2>Ingredients</h2>
{{ ingredients | metafield_tag }}
{%- endif -%}
{%- assign note = product.metafields.custom.care_note.value -%}
{%- if note != blank -%}
<p>{{ note | escape }}</p>
{%- endif -%}metafield_tag picks an HTML element by metafield type, but it doesn't support most list types yet. .value gives you the raw value. If a key is named size, first or last, use brackets (namespace["size"]), because those are filter names too. More in our metafields guide.
Loops with limits
A for loop runs at most 50 times. Past that you need paginate. Use limit to stop early, offset to skip items and else for an empty list.

Inside a loop, forloop tells you where you are: first, last, index (from 1), index0, length, rindex and parentloop. This one numbers items and loads the first two images eagerly, since shoppers see them without scrolling:
<ul class="product-strip">
{%- for item in collection.products limit: 8 -%}
{%- liquid
assign loading = 'lazy'
if forloop.index <= 2
assign loading = 'eager'
endif
-%}
<li>
<span>{{ forloop.index }} of {{ forloop.length }}</span>
<a href="{{ item.url }}">{{ item.title | escape }}</a>
{%- if item.featured_image -%}
{{ item.featured_image | image_url: width: 600 | image_tag: loading: loading, widths: '300, 450, 600' }}
{%- endif -%}
</li>
{%- else -%}
<li>No products in this collection yet.</li>
{%- endfor -%}
</ul>image_tag adds width, height and a srcset for you. If you don't set preload, it also lazy-loads images in sections further down the page.
For longer lists, the paginate tag takes between 1 and 250 items per page and stops at the 25,000th item:
{% paginate collection.products by 24 %}
{% for product in collection.products %}
{% render 'product-card', product: product %}
{% endfor %}
{{ paginate | default_pagination }}
{% endpaginate %}Array filters: find, has and reject
Shopify added find, find_index, has and reject on 11 February 2025. They take a property name and a value, and they replace a lot of small loops:
{%- assign large = product.variants | find: 'title', 'Large' -%}
{%- if large and large.available -%}
<p>Large is in stock.</p>
{%- endif -%}
{%- assign without_gift_cards = collection.products | reject: 'type', 'Gift Card' -%}What is new, and what is going away
| Date | Change | Status |
|---|---|---|
| 11 Feb 2025 | find, find_index, has, reject array filters | Live |
| 21 May 2025 | LiquidDoc with the doc tag | Live |
| 13 Jan 2026 | Stricter Liquid parsing for all themes | Enforced |
| Not dated | include tag | Deprecated, use render |
| 21 Jul 2026 | block and partial tags | Announced as a developer preview, now in the reference |
Stricter parsing. On 13 January 2026 Shopify started enforcing a stricter parser on themes. Code that doesn't meet it is rewritten automatically. The migration guide lists the usual failures:
- A filter inside a
renderargument. Assign it to a variable first. - A condition such as
settings.x or settings.yas arenderargument. Wrap therenderin anif. withcombined with key-value pairs, or a colon right afterwith.orandandinsideassignorcase. Logical operators belong inif.&&,||or parentheses in a condition. Writeandandor, with no grouping.

The fix for the first case looks like this:
{% assign alt_text = product.featured_image.alt | escape %}
{% render 'image', image: product.featured_image, alt: alt_text %}The block and partial tags. On 21 July 2026 Shopify announced a developer preview with two new tags. {% block %} renders a theme block straight from a Liquid template, much like render does for a snippet. {% partial %} marks a named region of server-rendered HTML that JavaScript can refresh without a full page reload. Both tags now have pages in the main Liquid reference. But we did not find a changelog post that announces general availability. Shopify's announcement says to try them on a development store created with the Liquid July '26 developer preview, so do that before you build a live theme on them. Shopify says existing themes keep working with sections, theme settings and JSON templates.
Performance habits that pay off
Shopify's performance guidance names the usual causes of slow Liquid: loops that grow with the catalogue, nested loops, metafield reads inside loops, and looping over more variants or products than the page shows. In practice:
- Avoid deeply nested loops. Each level multiplies the work as the catalogue grows.
- Read metafields once, outside the loop. Use theme settings for data that never changes.
- Don't loop over every variant when the first view only needs a few.
- Limit what you fetch. A
limitoncollection.productshelps. Other arrays needpaginate. - Assign repeated values before the loop, so a filter runs once instead of once per item.
The guide also suggests section.index and section.location to treat sections above the fold differently. To find slow lines, the Shopify Theme Inspector for Chrome shows Liquid render time as a flame graph. More habits are in our theme performance guide.
Debugging and Theme Check
Theme Check is Shopify's linter for the Liquid and JSON in a theme. It runs through Shopify CLI and comes built into the Shopify Liquid extension for Visual Studio Code.
shopify theme check
shopify theme check --auto-correct
Checks worth knowing, from the checks reference:
| Check | What it catches |
|---|---|
| UnknownFilter, UndefinedObject | Typos in filters and objects |
| UnusedAssign | Variables assigned and never used |
| DeprecatedTag | include and other deprecated tags |
| MissingRenderSnippetArguments | A required LiquidDoc parameter was not passed |
| ImgWidthAndHeight | img tags without width and height |
When something breaks, we work through it in this order:
- Run Theme Check. Most "my section vanished" bugs are syntax errors it names for you.
- Print the value:
<pre>{{ product.tags | json }}</pre>shows what Liquid really holds. Delete it before you publish. - Comment out code with
{% comment %}or{% # %}until the faulty line shows itself. - Work on a duplicate of the live theme, never the published one.
Hiring a Shopify Liquid developer: what to ask
Plenty of people can edit Liquid. Fewer leave a theme cleaner than they found it. Before you hand over a theme, ask:
- Will you work on a duplicate theme or a development store, and never on the live one?
- Will the code pass
shopify theme checkwith no errors? - Do you use
renderwith LiquidDoc for snippets, and noinclude? - How do you keep loops small, and do you read metafields outside them?
- Will the code parse under the stricter parser without being rewritten?
Clear answers to those tell you more than a portfolio. If you'd rather have someone else do it, we build and fix Shopify themes, from a single section to a custom theme. Tell us what you want to change and we'll say how we'd approach it.
Frequently asked questions
What is Shopify Liquid used for?
It builds Shopify themes. Liquid reads store data such as products, collections, the cart and theme settings, and prints it into HTML. Every Online Store theme is built from Liquid files.
Is Liquid a programming language?
It's a template language. It can branch, loop and format data, but its job is to read what Shopify provides and print HTML. It can't even create metafields. Anything that must store data or talk to another system belongs in an app or in JavaScript on the page.
What is the difference between {{ }} and {% %}?
Double curly braces print a value. Curly brace percentage delimiters run logic, such as a condition or a loop, and the tag text itself is not printed. Inside a {% liquid %} tag, use echo to print.
Is Liquid only used by Shopify?
No. Shopify created it and publishes it as open source, and other software projects use it too. But Shopify's theme version adds its own tags, filters and objects, so code from another platform won't always run in a theme.
Should I use include or render?
Use render. Shopify deprecated include because its shared variables reduce performance and make code harder to read. render isolates the snippet, so you pass in what it needs by name. Theme Check flags include.
Why does my if statement pass when the field is empty?
Because an empty string is truthy in Liquid. Only nil and false are falsy. Compare with blank, as in {% if section.settings.heading != blank %}. The same goes for 0 and empty arrays.
What changed with the January 2026 parser update?
From 13 January 2026 Shopify enforces stricter parsing on themes, and code that doesn't meet it is rewritten automatically. The usual causes are filters or conditions inside render arguments, and and or or inside assign or case. Run Theme Check and read the migration guide.
Can I use the new block and partial tags in a live store?
Test first. Shopify's announcement says to try them on a development store created with the Liquid July '26 developer preview. Shopify announced them as a developer preview on 21 July 2026. They now appear in the Liquid reference, but we found no announcement of general availability. Existing themes keep working with sections and JSON templates, so there is no need to migrate.
Sources
The main pages this guide rests on. Read the current version before you rely on a detail.
Shopify agency
We build, fix and grow Shopify stores.
Tell us what you are working on. We reply by email within one business day.
Work with Ecompanda


