Start building

Guides

Shopify Liquid errors: what each message means and how to fix it

Look up the words on your screen in the tables below. Then the walkthrough shows how to find the line, fix it safely and get back an earlier version if needed.

The Klorr teamUpdated 10 min read

  • Liquid
  • Errors
  • Debugging
  • Theme code

Key takeaways

  • A message like Liquid error (sections/header.liquid line 613) tells you the file and line where the problem shows, which isn't always where it was caused.
  • Syntax errors stop a file from saving. Runtime errors save fine and print on the page for customers, so check a preview after any edit.
  • Could not find asset snippets/... is most often left behind by an uninstalled app or deleted file.
  • Undefined variables give you an empty space and no error at all, so use Theme Check to catch them.

First, the ones that appear on your live pages, usually with a prefix such as Liquid error (sections/main-product.liquid line 42):. The page around them still renders. Exact wording can vary a little, because some come from Ruby or from Shopify's own filters.

Message after the prefixWhat it meansFix
Could not find asset snippets/x.liquidA render or include names a snippet that isn't in this theme. Very often an uninstalled app's leftover, or a deleted fileRestore the file, or delete the render line. Walkthrough below
comparison of String with 5 failed> or < was used between text and a number, often a metafield or text settingConvert first: assign n = value | plus: 0, then compare n
comparison of Integer with String failedThe same mismatch, the other way roundSame fix. Also check you aren't comparing a whole metafield where you meant its .value
divided by 0divided_by or modulo got zero, such as a discount sum on a product with no compare-at priceGuard it: if product.compare_at_price > 0 before dividing
Array 'x' is not paginateablepaginate was given something it can't page through, such as an array you built with filtersPaginate the original object (collection.products), then filter inside the loop
include usage is not allowed in this contextA snippet opened with render tries to use include. Liquid disables that combinationReplace include with render and pass variables explicitly
Memory limits exceededThe template built too much in one render, such as string concatenation in a large nested loopReduce the loops and avoid building giant strings. Limit how many items you iterate
Nesting too deepSnippets rendering each other past the depth limit, usually a snippet that ends up rendering itselfFind the cycle and break it
internalShopify hit an internal error rendering that piece. It carries little detailReload to see if it's temporary, then simplify the code around that line. If it persists, contact Shopify support with the URL

These come up when you save in the code editor, or when you upload a theme. The file won't save, so customers don't see them. They usually start with Liquid syntax error (line 12):.

MessageWhat it meansFix
'if' tag was never closedAn opening tag has no matching end. The same applies for for, unless, case, captureAdd {% endif %}, counting from the line named. A missing one inside an earlier block can shift the report
Unknown tag 'endif'An end tag has nothing to end, or a tag name is misspelledRemove the extra tag, or look for a typo in the opening one. A paste may have lost it
Unknown tag 'endschema'The file has {% endschema %} and the opening {% schema %} is damaged or missingRestore the opener exactly
Unexpected outer 'else' tagelse or elsif sits outside any ifAn endif was closed too early. Check nesting above it
Tag '{%' was not properly terminated with regexp: /\%\}/A {% was never closed with %}Look for {% if x } or a line break inside the tag
Variable '{{' was not properly terminated with regexp: /\}\}/A {{ was never closed with }}Often {{ x } or { x }}. Also check inline CSS or JS that contains double braces
Syntax Error in 'for loop' - Valid syntax: for [item] in [collection]A malformed loop. For loops require an 'in' clause is the same thingWrite {% for item in collection.products %}
Syntax Error in 'assign' - Valid syntax: assign [var] = [source]A malformed assignment, often a missing = or a space in the nameWrite one name, then =, then the value
Syntax Error in tag 'if' - Valid syntax: if [expression]The condition can't be parsed, often an empty if or a stray characterWrite a complete comparison. Filters don't belong in an if either, so assign the filtered value first
Syntax error in tag 'render' - Template name must be a quoted stringrender was given a variable as the namerender needs a fixed name in quotes. Use case to choose between snippets
Invalid JSON in tag 'schema'The section's settings block isn't valid JSONSee fixing invalid JSON in a schema
New schema is incompatible with the current setting valueSaved settings in a template don't fit your edited schema, such as a removed block type or select optionPut the old option back, or edit the template in the theme editor first, and then change the schema
Section type 'x' does not refer to an existing section fileA templates/*.json file or section group names a section file that doesn't exist. Theme Check's JSONMissingSection covers itRestore or rename the file, or remove that entry from the JSON

How to find the file and line

Take a real one: Liquid error (sections/header.liquid line 613): Could not find asset snippets/icon-cart.liquid. The brackets hold the file and line where Liquid was working when it failed. The words after the colon tell you what it wanted.

  1. Open the code editor on a duplicate

    In Online Store › Themes, duplicate the live theme if you can, then choose ⋯ › Edit code on the copy. For a page that's broken right now, editing live is reasonable if the fix is small.

  2. Go to the file

    Open the file named in the brackets, such as header.liquid under Sections. If no file is named, search for a word from the broken area.

  3. Search across the theme

    Shopify's code editor has a search icon in its left sidebar that shows every match across all files, with options for case and regular expressions. Use it to find every render that names a missing snippet, since one is rarely alone.

  4. Check the line, then a few above

    The named line may simply be where the bad value got used. Trace the variable upward to where it was assigned.

  5. Preview, then check the live page

    After saving, load the affected page. Use a product or collection that triggered the error, since many runtime errors depend on the data.

The last point catches people often. A divide-by-zero may show only on products with no compare-at price, and a metafield comparison only on products where that metafield is text. If an error appears on one product and not another, compare their data, not their templates.

To get a broken file back to how it was, open it and use the Timeline view: pick an earlier entry, compare it, and restore it. Shopify warns that history is finite, that restoring replaces the whole file, and that Timeline doesn't cover files in assets or recover deleted files. For a deleted file, copy it from a duplicate theme or a fresh install of the same theme from your theme library.

Fixing "Could not find asset"

This is the Liquid error merchants see most, so it gets its own walkthrough. It usually means an app installed code by editing your theme, and removing the app didn't remove the reference. Or someone copied a section from a tutorial without its snippet, or merged an update.

  1. Note the snippet's name. It often hints at where it came from: a review app's or a page builder's name in the file name is a giveaway.
  2. Search all theme files for that name, without .liquid. You may find several render lines.
  3. If you still use the feature, restore the snippet from a backup, from a duplicate theme, or by reinstalling the app. Removing the reference would lose the feature.
  4. If the app is gone for good, delete each render line. Delete only that line, not the whole section.
  5. Check names exactly: render 'Product-Card' won't find product-card.liquid.

If you can't fix it properly right now and customers are looking at the error, there is a stopgap. Create an empty snippet with exactly the missing name. The error goes away because the file now exists, and nothing renders. Come back and clean it up later.

The runtime fixes, in code

Most runtime errors come from code that assumed a value would be there or would have a certain type. Three small habits cover most of them.

section.liquid
{% comment %} Before: fails when compare_at_price is empty {% endcomment %}
{{ product.price | times: 100 | divided_by: product.compare_at_price }}

{% comment %} After: only divides when there is something to divide by {% endcomment %}
{%- if product.compare_at_price > product.price -%}
  {%- assign saved = product.compare_at_price | minus: product.price -%}
  {{ saved | times: 100 | divided_by: product.compare_at_price }}% off
{%- endif -%}

{% comment %} Before: fails if the metafield holds text {% endcomment %}
{% if product.metafields.custom.stock_alert.value > 5 %}...{% endif %}

{% comment %} After: plus: 0 turns the value into a number first {% endcomment %}
{%- assign stock_alert = product.metafields.custom.stock_alert.value | plus: 0 -%}
{% if stock_alert > 5 %}...{% endif %}

{% comment %} Filters can't sit inside an if. Assign first. {% endcomment %}
{%- assign kind = product.type | downcase -%}
{% if kind == 'candles' %}...{% endif %}

The bugs that show no error at all

Liquid tolerates a lot. Many mistakes produce nothing visible, which can be harder to track down than a message. If something is simply missing, check these before anything else:

SymptomLikely causeHow to spot it
Blank where a value should beAn undefined variable or misspelled property, like product.titelTemporarily print {{ thing | json }} to see what's there
The value isn't in the blockUsed section.settings.x where it should be block.settings.xCheck the id matches the schema exactly, in the right scope
A setting has no effectThe id in the code differs from the schema'sTheme Check, or search the file for the id
A loop outputs nothingfor over something that is empty or not iterable, or a when that doesn't matchPrint {{ list.size }} and check the type names' capitals
A metafield prints a blob, or nothingMissing .value, or wrong namespace and keyPrint {{ product.metafields.custom | json }}

Don't leave | json debug output behind on a live page, since it can reveal more data than you want to show. Wrap it in {% if request.design_mode %} while you work and remove it afterwards.

Catching them before customers do

If you edit themes often, Shopify's Theme Check finds most of this without opening a browser. It's built into the Shopify CLI as shopify theme check and into the VS Code extension. Its checks cover syntax errors, schema JSON, referenced files that don't exist and deprecated tags. Pull a copy with shopify theme pull, run the check, and read the errors first.

When an error appears after a theme update, the cause is usually an old edit. A file you customized and the update's new version have been merged, and a snippet was renamed in between. Compare with a clean copy of the theme's new version. If you're pasting code from elsewhere, including from an AI tool, a saved file only proves it parsed. It doesn't prove it works with your data, so test it on your odd products: no images, one variant, sold out, no compare-at price.

If the language itself is new to you, start with what Liquid is. If you'd rather not write section code by hand, Klorr's Shopify Liquid code generator writes a complete section from a description. Test what it gives you on those same odd products, as you would any code.

Questions, answered

What does Liquid error mean on Shopify?

Your theme's template code failed at that point on the page. The text in brackets names the file and line, and the rest of the message says what went wrong. The remainder of the page usually still renders.

How do I fix Liquid error: Could not find asset?

A render or include points to a snippet that isn't in your theme. Search your theme for the snippet's name, then either restore the file or delete the render line if the feature is gone. Uninstalled apps are the most common cause.

Why does a Liquid error show on only some products?

Runtime errors depend on data. A product with no compare-at price can trigger a divide by zero, and one whose metafield holds text can break a comparison. Compare a failing product's data with a working one's.

Do Liquid errors hurt SEO or sales?

A visible error is text on your page, seen by shoppers and search crawlers alike, and it may be sitting where a price or a button should be. It's worth fixing promptly, and checking which area of the page failed to render.

Can I undo a theme code change that caused a Liquid error?

Yes, for most files. Use the Timeline view on the file in Shopify's code editor to compare and restore an earlier version. It doesn't cover assets or deleted files, so keep a duplicate theme before larger edits.

Why does Shopify refuse to save my file?

It found a syntax error, usually an unclosed tag or invalid JSON in the schema. The message gives the line. Your last saved version keeps running in the meantime, so customers aren't affected.

Get the whole section written for you

Describe the section you want. Klorr writes the Liquid, the CSS, the schema and every theme-editor setting — code that lives in your theme and stays yours.