Fix My Error

Stuck? Solved.

Home › Fix Errors › Shopify › Liquid Errors
Liquid error: undefined method or syntax error

Fix: Shopify Liquid Errors

Liquid errors are cryptic. Here's how to decode the most common ones and fix them in seconds.

Last updated: October 2026

⚡ The 30-second fix

Match the error message to the cause. Liquid errors fall into three buckets:

1. Syntax error → unclosed tag, misspelled keyword, or wrong brackets
2. Undefined method → property doesn't exist, wrong object, or typos
3. Nil error → accessing a property on null (usually wrong scope)

Scroll down to match your exact error.

The three Liquid error types

1

Syntax errors

Liquid couldn't parse your template. The error message points to a specific line in a specific file. Go there and look for one of these:

{% comment %} ❌ Unclosed tags {% endcomment %}
{% if user %}
  Hello
            ← missing {% endif %}

{% for product in products %}
  {{ product.title }}
            ← missing {% endfor %}

{{ product.title }      ← missing closing brace
{% assign x = 5 }       ← missing closing % ({{ }} for output, {% %} for logic)

{% if user == 'admin' %}   ← wrong quotes for variable
{% if user = 'admin' %}    ← single = for assignment (not comparison)

Pro tip: Use an editor with Liquid syntax highlighting (VS Code + Shopify Liquid extension). Unclosed tags visually stick out — the color-coding breaks at the point of the error.

2

Undefined method / property errors

You're calling something that doesn't exist on the object. Usually a typo, wrong casing, or wrong object.

/* ❌ Typos */
{{ product.titel }}       → should be product.title
{{ collection.prodcuts }} → should be collection.products

/* ❌ Wrong casing (Liquid is case-sensitive) */
{{ Product.title }}       → should be product.title
{{ product.Title }}       → should be product.title

/* ❌ Wrong object */
{{ user.name }}           → there's no 'user' object in Shopify
                          → use customer or product or collection
                          → or {{ shop.customer_accounts_enabled }}

/* ❌ Wrong filter */
{{ product.price | uppercase }}  → uppercase only works on strings
                                 → use {{ product.price | money }}

Shopify objects are specific: product, collection, cart, customer, shop, page, blog, article, order, line_item, variant. There is no generic "user" or "item" object.

3

Nil / undefined variable errors

You're accessing a property on something that's null or undefined in this scope. Common with variables defined inside loops or conditionals.

/* ❌ Variable scope issue */
{% for item in cart.items %}
  {% assign total = item.price %}
{% endfor %}

{{ total }}  ← ❌ undefined, `total` was scoped to the loop

/* ✅ Correct — use a namespace or predeclare */
{% assign total = 0 %}
{% for item in cart.items %}
  {% assign total = total | plus: item.price %}
{% endfor %}

{{ total }}  ← ✅ works

/* ❌ Accessing null property */
{% if product.available %}
  {{ product.featured_image.src }}  ← ✅ safe, product exists
{% endif %}

{{ product.featured_image.src }}   ← ❌ fails if featured_image is nil

/* ✅ Use default filter */
{{ product.featured_image.src | default: 'no-image.png' }}

Liquid tip: Accessing a property on nil returns nil instead of throwing — but chaining nil properties throws. Use default filter or check with if first.

Debugging techniques that actually work

1. Dump the object as JSON. The fastest way to see what's available:

{{ product | json }}
{{ collection | json }}
{{ cart | json }}

// Output shows every property and value
// Find the exact property name you need

2. Add temporary output lines. Prints values so you can see what Liquid is actually working with:

DEBUG product: {{ product.title }}
DEBUG collection size: {{ collection.products.size }}
DEBUG first item: {{ collection.products.first.title }}

3. Use the Shopify Theme Check CLI. Catches syntax errors before you upload:

# Install Shopify CLI
npm install -g @shopify/cli @shopify/theme

# Run theme check on your theme folder
shopify theme check

# Output shows every syntax issue, missing object, or deprecated filter

4. Check Liquid's official object reference. Shopify's docs list every object and every property:

Search for the object name in Shopify's Liquid reference — the full property list is documented.

Common filter errors

Error Cause & fix
money filter fails Price stored as string, not cents. Prices in Shopify are in cents (integer). Format with | money only on price objects.
date filter fails Liquid expects a timestamp string. Convert with | date: '%Y-%m-%d' but ensure the input is a valid date string.
img_url fails Only works on image objects. {{ product.featured_image | img_url: '400x' }} — not on the string URL.
size on null Loop over empty collection. Use {% if collection.products.size > 0 %} before iterating.
for loop error Iterating over a non-array. Use {% for item in collection.products %} — not over single objects.

🛡️ How to prevent Liquid errors

❓ Frequently asked questions

How do I fix a Liquid syntax error in Shopify?

Check for unclosed tags, misspelled keywords, or wrong bracket types. Liquid requires matching {% %} for logic and {{ }} for output. Use a code editor with Liquid syntax highlighting to see unclosed tags visually.

What does 'Liquid error: undefined method' mean?

You're calling a method or property that doesn't exist on that object. Common cases: misspelled property (product.titel instead of product.title), calling a filter on the wrong type, or accessing an object that's null in that context.

Why is my Liquid variable undefined?

Liquid variables are scoped. Variables defined inside a {% for %} or {% if %} block aren't visible outside it. Also check that you're accessing the right object — Shopify Liquid objects are named specifically (product, collection, cart, etc.).

Is Liquid case-sensitive?

Yes. Liquid keywords (if, for, assign, endfor) are lowercase. Shopify objects (product, collection) are lowercase. Property names (title, price, url) are lowercase. Using Title instead of title fails silently or throws an error.

How do I debug Liquid templates?

Use the {{ object | json }} filter to dump an object's full structure. Or install Shopify's theme-check tool via the Shopify CLI — it catches syntax errors before you upload.

🔗 Related fixes

← All Shopify Fixes