Understanding Liquid Types
Liquid is dynamically typed. You do not declare types, but knowing how Shopify represents data prevents subtle bugs — especially when comparing values in {% if %} tags or passing data to JavaScript.
- String — text in single or double quotes: "Hello" or 'World'
- Number — integers and decimals: 42, 3.14. Money is stored as integers in cents (1899 = $18.99)
- Boolean — true or false (lowercase only in Liquid comparisons)
- Nil — represents empty/missing values; falsy in conditionals
- Array — ordered lists: product.images, cart.items, collection.products
- Object (Drop) — Shopify wrappers: product, collection, shop — expose properties and methods
Truthy and Falsy Values
In {% if %} tags, nil and false are falsy. Empty strings, zero, and empty arrays are truthy in Liquid (unlike JavaScript). Always compare explicitly when checking for empty collections.
Explicit nil and size checks
{% if product == nil %}
<p>Product not found — check the handle or publish status.</p>
{% endif %}
{% if collection.products.size > 0 %}
<p>Showing {{ collection.products.size }} of {{ collection.all_products_count }} products</p>
{% else %}
<p>No products in this collection yet.</p>
{% endif %}Tip: Use | default: 'fallback' on output tags when a metafield or setting might be blank, so merchants never see empty UI gaps.