Skip to content

if

Renders a block when a condition is true.

Combine conditions with and / or (evaluated right to left, no parentheses). Compare with ==, !=, >, <, >=, <= and contains. Only false and nil are falsy; empty strings and 0 are truthy, so test for emptiness with blank or empty.

{% if condition %}…{% elsif other %}…{% else %}…{% endif %}
Liquid
{% if product.available %}In stock{% else %}Sold out{% endif %}
Output
In stock
Liquid
{% if product.description != blank %}Has a description{% endif %}{% if cart.items == empty %} · empty cart{% else %} · {{ cart.item_count }} items{% endif %}
Output
Has a description · 3 items

Shopify: Same as Shopify.

Since theme platform 1.0.

Was this page helpful?