Liquid · Shopify

On this page 7

Liquid is the open-source template language created by Shopify that renders storefront pages by combining fixed markup with live store data such as products, collections, carts and customer accounts. Among e-commerce store platforms, it is the layer that separates theme presentation from commerce logic: merchants and developers control what a page looks like, while Shopify keeps checkout, pricing and inventory on its own servers.

Liquid is deliberately safe and non-Turing-complete in practice: it cannot open files, call arbitrary code or run unbounded loops, which allows Shopify to execute millions of merchant-edited templates on shared infrastructure. Not to be confused with liquidity in finance or with unrelated products that share the name.

How Liquid renders a Shopify storefront

Liquid works as a server-side rendering step that runs every time a visitor requests a storefront page. Shopify selects the matching theme template, loads the relevant objects for that URL, evaluates every Liquid expression and sends finished HTML to the browser, often from a cached edge copy.

A template mixes plain HTML with three kinds of Liquid syntax. Objects in double curly braces print data, tags in curly-brace-percent delimiters control logic, and filters after a pipe character transform output. For example, {{ product.price | money }} reads the price in the smallest currency unit and formats it according to the store currency settings.

The following table summarizes the three building blocks and what each one does during rendering.

ElementDelimiterPurposeTypical example
Objects{{ }}Output a value from store dataproduct.title, cart.item_count
Tags{% %}Control flow, loops and variable assignmentif, for, assign, render
FiltersPipe after an objectTransform or format outputmoney, img_url, upcase, date
Whitespace controlHyphen inside delimitersTrim surrounding spaces and line breaks{%- if -%}
Core syntax elements of Liquid

Because the language is sandboxed by design, a template can only read the objects Shopify exposes in that context. A product page can access product, a collection page can access collection, and global objects such as shop, settings and request are available everywhere.

Theme architecture and file types

Modern Shopify themes follow the Online Store 2.0 architecture, in which Liquid files are organized into layouts, templates, sections, blocks and snippets. Since that release, most page templates are JSON files that list sections, while the actual markup lives in Liquid section files that merchants can rearrange in the theme editor.

Each file type plays a distinct role in the rendering chain, as the next table shows.

File typeFolderRoleEditable by merchants
LayoutlayoutOuter HTML shell, head tags and global scriptsNo, code only
TemplatetemplatesDefines which sections a page type usesYes, through the theme editor
SectionsectionsReusable module with its own schema and settingsYes, add, remove and reorder
Blockblocks or inside sectionsSmaller repeatable unit inside a sectionYes, add and reorder
SnippetsnippetsPartial file included with the render tagNo, code only
Liquid file types in an Online Store 2.0 theme

Every section ends with a schema tag that declares settings in JSON. These settings generate the controls in the theme editor, so a developer writes Liquid once and a merchant later changes text, colors or product pickers without touching code. This division of labor is the main reason Liquid themes scale from small shops to Shopify Plus brands.

Liquid compared with other storefront approaches

Liquid represents the classic coupled storefront model, in which the platform hosts both the data and the rendering. Other store platforms and architectures make different trade-offs between control, speed of development and operational burden.

ApproachWhere rendering happensMain strengthMain cost
Liquid themesShopify serversHosted, fast to launch, merchant editableLimited logic, no custom server code
Shopify HydrogenDeveloper-hosted or Oxygen runtimeFull React control over the frontendHigher build and maintenance effort
WooCommerce PHP templatesMerchant web serverUnrestricted PHP and plugin accessHosting, security and updates are on the merchant
Generic headless frontendAny framework or CDNChannel independenceSeparate content, preview and checkout integration
Liquid versus alternative storefront technologies

In practice, Liquid remains the default for the large majority of Shopify stores, while headless commerce is chosen when a brand needs app-like interactivity or a shared frontend across several back ends. Many teams combine both, keeping checkout and account pages on Shopify while experimenting with custom frontends elsewhere.

Practical development with Liquid

Professional Liquid development relies on the Shopify CLI, which serves a local preview against real store data, syncs files to a development theme and runs Theme Check, a linter that flags deprecated tags, missing translations and performance problems. Version control through the GitHub integration keeps theme code reviewable.

The choice of technique depends on what the store needs, as the decision table below illustrates.

RequirementRecommended techniqueReason
Show extra product dataMetafields read in LiquidStructured data without hardcoding text
Reusable UI fragmentrender tag with snippetsIsolated scope prevents variable leaks
Merchant-controlled layoutSections with schema settingsEditing happens in the theme editor
Responsive product imagesimage_url and image_tag filtersShopify CDN resizes and serves modern formats
Dynamic cart updatesSection Rendering API with JavaScriptRefreshes Liquid output without a full reload
Choosing a Liquid technique for common store requirements

Metafields and metaobjects deserve special attention because they extend the data model that Liquid can read. A developer defines a metafield such as material or care instructions, the merchant fills it per product, and the template prints it with product.metafields.custom.material, which keeps content and code cleanly separated.

Limitations and common mistakes

The sandbox that makes Liquid safe also defines its hard limits. It cannot call external APIs during rendering, cannot write data, and has no access to checkout pages on standard plans, which are customized through checkout extensibility rather than Liquid.

  • Pagination limits: a for loop over a collection returns at most 50 items unless the paginate tag is used, and paginate allows up to 250 per page.
  • Nested loops over large collections slow server rendering and can produce render timeouts on busy pages.
  • Using include instead of render: the deprecated include tag shares variables with the parent template and makes bugs hard to trace.
  • Hardcoded text instead of locale files blocks translation and multi-market selling.
  • Logic in Liquid that belongs in apps, such as complex discount calculations, which should run in Shopify Functions instead.

A further misconception is that Liquid output is always fresh. Shopify caches rendered pages, so personalized content that varies per visitor is better loaded through JavaScript and the storefront APIs rather than computed in the template.

A non-technical view

Think of a Shopify store as a printed catalog that rewrites itself every time someone opens it. Liquid is the set of instructions that tells the system where to put each product name, photo and price on the page.

The designer writes the layout once and leaves blanks such as “insert price here.” When a shopper visits, Shopify fills in the blanks with current data. If a price changes or an item sells out, every page shows the update automatically, without anyone redesigning anything.

A concrete example

A mid-sized outdoor apparel store on Shopify sells 600 jackets, each with a different waterproof rating. The merchandising team wants that rating shown as a badge on product and collection pages, but the theme only displays title, price and images.

A developer creates a numeric product metafield for the waterproof rating in millimeters, adds a small snippet that prints a badge when the value is 10,000 or higher, and renders it in the product card and the main product section. The merchandisers then fill the field through a bulk spreadsheet import.

The change takes about one working day, requires no app subscription and no theme rebuild, and the badge updates automatically whenever the team edits a product. After launch, the store reports fewer customer questions about rain protection, because the key specification is now visible before shoppers open a product page.