Skip to main content

Qalab Basics

Core concepts for working with Qalab templates.

Handles

Handles are URL-friendly identifiers for store resources (products, collections, pages).

{{ product.handle }}        {# health-potion #}
{{ collection.handle }} {# summer-sale #}

Handle rules:

  • Always lowercase
  • Spaces become hyphens
  • Special characters removed
  • Must be unique (duplicates get -1, -2, etc.)

Accessing by Handle

{# Square bracket notation #}
{{ pages['about-us'].url }}

{# Dot notation #}
{{ settings.header_color }}

Operators

Comparison

OperatorMeaning
==equals
!=not equals
>greater than
<less than
>=greater or equal
<=less or equal

Logical

OperatorMeaning
andboth true
oreither true
containsstring/array contains value
{% if product.price > 100 and product.available %}
Premium product in stock
{% endif %}

{% if product.tags contains 'sale' %}
On sale!
{% endif %}

Data Types

TypeExample
string"Hello" or 'Hello'
number42, 3.14
booleantrue, false
nullundefined value
array[1, 2, 3]

Truthy and Falsy

Only false and null are falsy. Everything else is truthy:

{# Empty string is truthy - use blank to check #}
{% if settings.title != blank %}
{{ settings.title }}
{% endif %}

{# Empty object is truthy - use empty to check #}
{% if product != empty %}
{{ product.title }}
{% endif %}

Whitespace Control

Add hyphens to remove whitespace:

{# With whitespace #}
{% if true %}
Hello
{% endif %}

{# Without whitespace #}
{%- if true -%}
Hello
{%- endif -%}