Guide
Shopify Liquid Cheat Sheet 2026
Logic and Control-Flow Tags
Tags control what renders and when. Expand any tag to see what it does and a working example.
{% comment %}
Everything between the tags is ignored and never rendered. Use it for developer notes.
{% comment %}Hide until launch{% endcomment %}{% raw %}
Outputs Liquid code literally without processing it — useful when a JavaScript template library also uses curly braces.
{% raw %}{{ this is not processed }}{% endraw %}{% if %}
Renders a block only when a condition is true. Chain with elsif and else.
{% if cart.item_count > 0 %}
Cart has items
{% elsif customer %}
Welcome back
{% else %}
Your cart is empty
{% endif %}{% unless %}
The opposite of if: renders the block only when the condition is false.
{% unless product.available %}Sold out{% endunless %}{% case %}
Compares one variable against several values — cleaner than long elsif chains.
{% case product.type %}
{% when 'Shirt' %}Shirt sizing
{% when 'Shoe', 'Boot' %}Shoe sizing
{% else %}Standard sizing
{% endcase %}{% cycle %}
Inside a loop, outputs the next string from a list each time — typically for alternating classes.
{% for item in cart.items %}
<li class="{% cycle 'odd', 'even' %}">{{ item.title }}</li>
{% endfor %}{% for %}
Loops over an array or range. Supports limit, offset, reversed, an else block for empty arrays, and break / continue.
{% for product in collection.products limit: 4 %}
{{ product.title }}
{% else %}
No products found.
{% endfor %}{% tablerow %}
Loops like for but outputs HTML table rows and cells. Set columns with cols.
<table>
{% tablerow product in collection.products cols: 3 %}
{{ product.title }}
{% endtablerow %}
</table>{% assign %}
Creates or overwrites a variable.
{% assign sale = true %}
{% assign price = product.price | money %}{% increment %}
Creates a counter starting at 0 and adds 1 each time it is called. It is separate from variables created with assign, even with the same name. Not new — it has been part of Liquid for years.
{% increment count %} → 0
{% increment count %} → 1{% decrement %}
Creates a counter starting at -1 and subtracts 1 each time it is called. Also independent of assign variables.
{% decrement count %} → -1
{% decrement count %} → -2{% capture %}
Captures everything rendered between the tags into a string variable.
{% capture greeting %}Hello, {{ customer.first_name }}{% endcapture %}
{{ greeting }}{% include %} → use {% render %}
Legacyinclude shares all parent variables, which makes snippets hard to debug and slows rendering. Use render, which isolates the snippet and passes only the variables you name.
{% comment %} Old {% endcomment %}
{% include 'product-card' %}
{% comment %} Current {% endcomment %}
{% render 'product-card', product: product %}{% liquid %} and {% echo %}
Writes several tags in one block without repeating delimiters. Use echo to output inside it.
{% liquid
assign title = product.title | upcase
if product.available
echo title
endif
%}Shopify stores that convert, rank higher, scale and sell more.
Builds, SEO and CRO from a Shopify Plus partner team.
Monthly send · Unsubscribe any time · Privacy policy
Shopify experts
Let's talk ecommerce, Shopify & Shopify Plus solutions.
DROPSHIP HUBS helps ecommerce brands build, improve, and grow Shopify stores. We support new builds, migrations, ongoing development, SEO, and conversion optimisation.
Our team can help plan the right approach based on your store, goals, and current challenges.
Get in touch




