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.
Syntax
Section titled “Syntax”{% if condition %}…{% elsif other %}…{% else %}…{% endif %}Examples
Section titled “Examples”{% if product.available %}In stock{% else %}Sold out{% endif %}In stockTesting for empty values
Section titled “Testing for empty values”{% if product.description != blank %}Has a description{% endif %}{% if cart.items == empty %} · empty cart{% else %} · {{ cart.item_count }} items{% endif %}Has a description · 3 itemsRelated
Section titled “Related”Compatibility
Section titled “Compatibility”Shopify: Same as Shopify.
Since theme platform 1.0.
Was this page helpful?

