MyShopy Help Center
Help Center › Themes & templates

Liquid reference

Objects, tags and filters available in sections, snippets and the layout.

Themes use Liquid, the same template language Shopify uses. Most Shopify theme code works with little or no change. Liquid here is sandboxed: it can't run JavaScript on the server, and loops and rendering time are limited.

Global objects#

ObjectAvailable onHighlights
shopevery pagename, email, phone, description, currency, url, domain, logo, address, policies
settingsevery pageTheme settings, e.g. settings.color_accent (list)
routesevery pageroot_url, cart_url, cart_add_url, account_url, account_login_url, search_url, collections_url, all_products_collection_url, predictive_search_url
requestevery pagepath, host, page_type, design_mode (true inside the visual editor)
templateevery pagetemplate.name (e.g. product), template.suffix
cartevery pageitem_count, total_price, items (title, quantity, final_line_price, image, url, variant_title…), note
customerevery pageThe logged-in customer or nil
collectionsevery pagecollections['handle'] or collections.all → title, description, image, url, products, all_products_count
all_productsevery pageall_products['handle'] → a product
pagesevery pagepages['handle'] → title, content, url
linklistsevery pagelinklists['main-menu'].links → title, url, active, links (nested)
productproduct pagesee below
collectioncollection pageproducts (paginated), sort_by, sort_options, all_products_count
pagecontent pagestitle, content, handle
page_title, page_description, canonical_urlevery pageSEO values for the layout <head>

product#

id, title, handle, url, description, vendor, type, tags, price, price_min, price_max, price_varies, compare_at_price, available, featured_image, images, media, options, options_with_values, variants, has_only_default_variant, selected_or_first_available_variant, first_available_variant, seo_title, seo_description, created_at.

Each variant has id, title, price, compare_at_price, available, sku, inventory_quantity, option1…3, image.

Prices are in the smallest currency unit (paise). Always output them through a money filter: {{ product.price | money }}.

Tags#

TagExample
if / elsif / else / unless{% if product.available %}…{% else %}Sold out{% endif %}
case / when{% case block.type %}{% when 'heading' %}…{% endcase %}
for (with limit, offset, reversed, forloop), break, continue, cycle, tablerow{% for p in collection.products limit: 4 %}{{ forloop.index }}{% endfor %}
assign, capture, increment, decrement`{% assign sale = product.compare_at_price \minus: product.price %}`
render{% render 'product-card', product: p, show_vendor: true %}
section / sections{% sections 'header-group' %} (layout only)
form{% form 'product', product %}…{% endform %}, also 'contact', 'customer_login', 'create_customer', 'customer_address'
paginate{% paginate collection.products by 24 %}…{% render 'pagination', paginate: paginate %}{% endpaginate %}
style{% style %}.x{color:{{ settings.color_accent }}}{% endstyle %}
liquid, echoSeveral statements in one tag, one per line: {% liquid ⏎ assign a = 1 ⏎ echo a ⏎ %}
raw, commentOutput Liquid literally / leave notes

Whitespace control ({%- / -%}) is supported.

Built-in snippets#

SnippetParameters
product-cardproduct, plus optional show_vendor, quick_add
product-card-placeholder(none). Shown when a collection is empty
priceproduct or variant
paginationpaginate
product-mainproduct, section, compact. The full product form used by main-product and featured-product
iconname (e.g. cart, search, truck, shield, return)

Filters#

Money: money, money_with_currency, money_without_currency, money_without_trailing_zeros

Images and assets: image_url: width: 800 (also height, crop), img_url, image_tag, placeholder_image, placeholder_svg_tag, asset_url, file_url, stylesheet_tag, script_tag

Text: escape, escape_once, upcase, downcase, capitalize, append, prepend, replace, replace_first, remove, remove_first, strip, lstrip, rstrip, strip_html, strip_newlines, newline_to_br, truncate, truncatewords, split, slice, pluralize, handleize, camelize, highlight, url_encode, url_escape, url_param_escape, link_to, within, t

Math: plus, minus, times, divided_by, modulo, abs, round, ceil, floor, at_least, at_most

Arrays: join, first, last, size, reverse, sort, sort_natural, uniq, compact, map, where, concat, sum

Other: default, json, date: "%d %b %Y", weight_with_unit, color_to_rgb, color_modify, font_family, md5, sha256, base64_encode, structured_data

Example: a product grid#

{%- assign c = collections[section.settings.collection] | default: collections.all -%}
<div class="section-pad"><div class="container">
  <h2 class="h-lg">{{ c.title | escape }}</h2>
  <div class="product-grid" style="--cols: 4; --cols-m: 2">
    {%- for p in c.products limit: 8 -%}
      {% render 'product-card', product: p %}
    {%- else -%}
      {%- for i in (1..4) -%}{% render 'product-card-placeholder' %}{%- endfor -%}
    {%- endfor -%}
  </div>
</div></div>
Didn’t find what you need?Contact support