Twig reference
Every variable, function and filter a website theme can use, each with a copy-ready example and its result.
Twig reference
This page lists everything a website theme template can use: the variables each page gets, the functions that read the business's menus, products, pages and settings, and the filters that format values. Every entry has a small example you can paste into a section and the result you see.
Printed documents, emails and SMS use the same template language with a shorter list. See Printed documents and receipts and Email and SMS templates.
When you use this
- You write a section and need the right function to show products, a menu, a slider or a form.
- You need the exact name of a value, such as a product's price or a page's text.
- You format a price, a date or an amount in words.
- An example in a shipped theme uses a function you do not know yet.
Theme structure
| File or folder in your theme | Where this reference applies |
|---|---|
layouts/base.html |
header, content, meta, group(), theme_css(), settings('id'), locale() |
sections/<name>.html |
everything on this page; settings.<id>, section and block are the section's own values |
snippets/<name>.html |
everything, plus the variables you pass with snippet('name', { ... }) |
config/settings_schema.json |
the theme settings read with settings('id') |
locale/<locale>.json |
the fixed words read with t('key', 'Default') |
assets/ |
files printed with the asset_url filter |
How it works
- Print a value with
{{ ... }}:{{ settings.heading }},{{ shop('name') }}. Values are made safe for HTML automatically. - Run a rule with
{% ... %}:{% if ... %},{% for ... in ... %},{% set ... = ... %}. - Call a function to read data:
get_products('featured', 'limit:4'),menu(settings.menu). - Use a filter after
|to change a value:{{ 1250|currency_sign }},{{ 'css/theme.css'|asset_url }}. - Check it in the Theme Studio preview before you publish.
Example: Show four featured products
<section class="section color-{{ settings.scheme }}" {{ section.attributes }}>
<div class="container">
<h2>{{ settings.heading }}</h2>
<div class="grid grid--4">
{% for product in get_products('featured', 'limit:4') %}
<article class="card">
<a href="{{ product.link }}">
{% if product.image_link %}<img src="{{ product.image_link }}" alt="{{ product.name }}" loading="lazy">{% endif %}
<h3>{{ product.name }}</h3>
</a>
<p class="price">{{ currency_sign() }} {{ product.net_sale_price }}</p>
</article>
{% else %}
<p class="muted">{{ t('product.none', 'No products yet.') }}</p>
{% endfor %}
</div>
</div>
</section>
Result: Four cards with the picture, name and price (for example "৳ 450.00") of products marked Featured. Each card opens the product page. With no featured products, the text "No products yet." shows.
Example: Main menu with drop-down items
{% set main_menu = settings.menu ? menu(settings.menu) : [] %}
<ul class="nav">
{% for item in main_menu.id is defined ? (main_menu.id|menu_item) : [] %}
{% set children = item.id|sub_item %}
<li>
<a href="{{ item.link }}"{% if item.target %} target="{{ item.target }}"{% endif %}>{{ item.name }}</a>
{% if children %}
<ul>{% for child in children %}<li><a href="{{ child.link }}">{{ child.name }}</a></li>{% endfor %}</ul>
{% endif %}
</li>
{% else %}
<li><a href="{{ route_home() }}">{{ t('nav.home', 'Home') }}</a></li>
{% endfor %}
</ul>
The section needs a menu setting: { "id": "menu", "type": "menu", "label": "Menu", "default": "" }.
Result: The menu the business picks in the builder (made in Website › Menu) shows with its sub-items under each item. Before a menu is picked, a single Home link shows.
Every function, filter and variable
Page variables
| Variable | Where | What it holds |
|---|---|---|
settings |
every section | the section's own values: settings.heading |
section |
every section | section.id, section.type, section.settings, section.blocks, section.attributes |
block |
inside {% for block in section.blocks %} |
block.id, block.type, block.settings, block.attributes |
shop |
everywhere | the business's public details: shop.name, shop.email, shop.mobile, shop.address, shop.logo … |
meta |
everywhere | meta.title, meta.description, meta.image of the page |
header |
layout | Sylloo's own styles and scripts (cart, sign-in, forms); print it in <head> |
content |
layout | the printed sections of the page |
page |
home, page |
the page from Website › Pages: page.name, page.content, page.image, page.link … |
pages |
pages |
the page list: pages.data and pages.meta (for pagination) |
blog |
blog |
one blog post (same keys as page, plus blog.blog_img) |
blogs |
blogs |
the post list: blogs.data and blogs.meta |
product |
product |
product.name, product.code, product.sale_price, product.net_sale_price, product.discount, product.image_link, product.images, product.description, product.available_stock, product.brand_name, product.categories … |
products |
products |
the product list: products.data and products.meta |
<h1>{{ page.name }}</h1>
{% if page.content %}{{ page.content|raw }}{% else %}<p class="muted">{{ t('page.empty', 'This page has no content yet.') }}</p>{% endif %}
Result: On a content page, the page name as the heading and the text the business wrote in Website › Pages, with its formatting.
Use
|rawonly onpage.content,blog.contentandproduct.description. Everything else must stay escaped.
settings
settings.<id> is a value of the current section. settings('id') (with brackets) is a theme setting from config/settings_schema.json. Without an id, settings() returns all theme settings. The filter form 'id'|settings works the same as settings('id').
<p class="tagline">{{ settings('tagline') }}</p>
<h2>{{ settings.heading }}</h2>
Result: The tagline from the theme settings ("Trusted local experts" by default) and the heading of this section.
shop
shop('key') returns one public detail of the business: name, title, slogan, logo, favicon, description, email, mobile, phone, address, website_address, support_email, support_mobile, support_phone, support_address, facebook_link, twitter_link, instagram_link, linkedin_link, youtube_link, tiktok_link, pinterest_link, whatsapp, whatsapp_link, telegram_link, meta_title, meta_description, meta_keyword, currency_sign, currency, languages. Any other key returns nothing.
<p>{{ shop('name') }} · <a href="tel:{{ shop('mobile') }}">{{ shop('mobile') }}</a></p>
Result: The business name and its mobile number as a tap-to-call link, as set in the business settings.
group
Prints a section group: group('header') prints groups/header.json.
{{ group('header') }}
<main id="main">{{ content }}</main>
{{ group('footer') }}
Result: The header sections, the page, then the footer sections.
theme_css
Prints the theme's design as CSS variables: --page-width, --section-gap, --font-heading, --font-body, --font-scale, --radius and, for each colour scheme, .color-<scheme> with --color-background, --color-text, --color-primary, --color-primary-text, --color-secondary, --color-border.
{{ theme_css() }}
Result: A <style> tag such as :root{--page-width:1200px;--section-gap:3rem;...}. Your CSS then uses var(--color-primary), and the colours follow the business's choices.
snippet
Prints snippets/<name>.html. The second argument passes variables to it.
{{ snippet('product_card', { product: product }) }}
Result: The product card design from snippets/product_card.html, filled with this product.
media
Returns the address of a picture chosen in a media setting (from the File Manager), a full web address as it is, or a file of your theme's assets/. The second argument asks for a smaller copy: {width: 900} or {size: 'thumb'} / {size: 'medium'}. Returns nothing when the setting is empty.
{% if media(settings.image) %}
<img src="{{ media(settings.image, {width: 900}) }}" alt="{{ settings.image_alt }}" loading="lazy">
{% endif %}
Result: The picture the business chose, in a size that loads fast. Without a picture, nothing is printed.
link
Returns the address of a url setting. A path such as /products gets the visitor's language added (/en/products). Unsafe links return nothing.
{% if link(settings.button_link) %}<a class="btn" href="{{ link(settings.button_link) }}">{{ settings.button_label }}</a>{% endif %}
Result: A button that opens the page the business typed in Button link, in the visitor's language.
editable
Marks a text so the business can click it in the website builder and type a new value. Prints nothing for visitors.
<h2 {{ editable('heading') }}>{{ settings.heading }}</h2>
Result: In the builder, a click on the heading lets the business edit it on the page. Visitors see a normal heading.
richtext
Prints a richtext setting as formatted text (bold, links, lists), cleaned of anything unsafe.
<div class="rte">{{ richtext(settings.text) }}</div>
Result: The formatted text the business wrote in the section's Text setting.
t
Returns a fixed word of your theme from locale/<locale>.json in the visitor's language. Nested keys use dots. If no file has the key, it returns the default.
<button type="button">{{ t('product.add_to_cart', 'Add to cart') }}</button>
Result: "Add to cart" for English visitors, and the Bangla or Finnish words when locale/bn.json or locale/fi.json has the key.
trans
Returns one of Sylloo's own built-in words (function trans('key') or filter 'key'|trans). For the words of your theme, use t().
<a href="{{ route_blogs() }}">{{ 'blog'|trans }}</a>
Result: "Blog" in the visitor's language.
locale
Returns the visitor's language code.
<html lang="{{ locale() }}">
Result: <html lang="en"> for English visitors, <html lang="bn"> for Bangla visitors.
product_list
Returns the products chosen in a product_list setting (category, brand, sort and number, set in the builder).
{% for product in product_list(settings.products) %}{{ snippet('product_card', { product: product }) }}{% endfor %}
Result: The products the business picked for this section, as product cards (8 by default, at most 48).
outlet
Returns an outlet's public details (name, address, phone, mobile, email) from an outlet setting; without a setting, the default outlet.
{% set branch = outlet(settings.outlet) %}
{% if branch %}<p>{{ branch.name }} · {{ branch.address }} · {{ branch.mobile }}</p>{% endif %}
Result: The name, address and mobile number of the outlet chosen in the section.
feature
Returns whether the business has a feature switched on. Use it to hide shop parts when the business does not sell online.
{% if feature('product') %}<a href="{{ route_products() }}">{{ t('nav.shop', 'Shop') }}</a>{% endif %}
Result: The Shop link shows only when the business uses products.
currency_sign
The function currency_sign() returns the business's currency symbol. The filter |currency_sign formats a number as an amount with the symbol.
<span>{{ currency_sign() }} {{ product.net_sale_price }}</span>
<span>{{ 1250|currency_sign }}</span>
Result: "৳ 450.00" and "1,250.00 ৳" for a business that uses taka.
payment_methods, shipping_methods, countries, languages
Lists for checkout and contact forms: the payment methods and shipping methods the business offers (name, charge), all countries (id, name), and the business's storefront language list.
<ul>{% for method in payment_methods() %}<li>{{ method.name }}</li>{% endfor %}</ul>
<ul>{% for method in shipping_methods() %}<li>{{ method.name }} ({{ method.charge }})</li>{% endfor %}</ul>
<select name="country">{% for country in countries() %}<option value="{{ country.id }}">{{ country.name }}</option>{% endfor %}</select>
{% if languages() %}<p>{{ t('general.languages', 'Languages') }}</p>{% endif %}
Result: A list of payment methods such as "Cash on delivery", a list of shipping methods with their charge, a country drop-down, and the "Languages" line only when the business has a language list.
Product, blog, category and brand lists: find_, get_, all_
Each kind of record has three functions. find_<name> returns one record (or nothing), get_<name> and all_<name> return a list (20 by default, at most 100). You pass text arguments in any order; an argument the function does not know is ignored.
| Functions | Arguments besides the shared ones |
|---|---|
find_products, get_products, all_products |
featured, top_rated, top_sales, code:<code>, brand:<id>, category:<ids> (sub-categories included), category_url:<slug>, unit:<id>, type:<type> |
find_blog, get_blog, all_blog |
category:<slugs or ids> (lists have short_content, not content) |
find_category, get_category, all_category |
featured, category:<parent id>, category_url:<parent slug>; get_ lists top-level categories, all_ every category |
find_subcategory, get_subcategory, all_subcategory |
the same, sub-categories only |
find_brand, get_brand, all_brand |
featured |
Shared arguments: limit:8, random, latest, oldest, id:<ids>, url:<slugs>.
{% for post in get_blog('latest', 'limit:3') %}
<article><a href="{{ post.link }}">{{ post.name }}</a><p>{{ post.short_content }}</p></article>
{% endfor %}
{% set brand = find_brand('url:acme') %}
{% if brand %}<img src="{{ brand.image_link }}" alt="{{ brand.name }}">{% endif %}
{% for category in get_category('featured', 'limit:6') %}<a href="{{ category.link }}">{{ category.name }} ({{ category.product_count }})</a>{% endfor %}
Result: The three newest blog posts with their short text, the logo of the brand whose web address is "acme", and six featured categories with their number of products.
category_tree, category_children, category_path
category_tree('depth:2', 'limit:100') returns top-level categories with their sub-categories in children. category_children(category) returns the direct sub-categories of a category (id or web address). category_path(category) returns the categories from the top down to this one, for a breadcrumb.
{% for category in category_tree('depth:2') %}
<a href="{{ category.link }}">{{ category.name }}</a>
{% for child in category.children %}<a href="{{ child.link }}">{{ child.name }}</a>{% endfor %}
{% endfor %}
{% for crumb in category_path('shirts') %} / <a href="{{ crumb.link }}">{{ crumb.name }}</a>{% endfor %}
Result: A two-level category menu, and the breadcrumb "/ Clothing / Shirts" for the category whose web address is "shirts".
find_page
Returns one published content page from Website › Pages by its web address or id, or nothing.
{% set about = find_page('about-us') %}
{% if about %}<h2>{{ about.name }}</h2><p>{{ about.short_content }}</p><a href="{{ about.link }}">{{ t('general.learn_more', 'Learn more') }}</a>{% endif %}
Result: The name, short text and a Learn more link of the "About us" page.
menu, menu_item, sub_item, menu_subItem
menu(id or position) returns a menu from Website › Menu (id, name, position) or nothing. The filter menu.id|menu_item returns its top-level items; item.id|sub_item returns the sub-items of an item. The functions menu_item('main_menu') (top-level items of the menu in that position) and menu_subItem(item.id) do the same. Item keys: id, parent_id, level, name, sub_title, link, icon, image_link, target, has_children.
{% for item in menu_item('footer_menu') %}<a href="{{ item.link }}">{{ item.name }}</a>{% endfor %}
Result: The top-level links of the menu the business placed in the footer position. See also the menu example near the top of this page.
slider, slider_items
slider(settings.slider) returns a slider from Website › Slider with its settings and the slides that are shown now (items, each with title, sub_title, short_description, image_link, mobile_image_link, image_alt, link, button_text …). Print it with the shipped slider snippet. slider_items(id, 'limit:3') returns only the slides.
{% set found = slider(settings.slider) %}
{% if found.items ?? false %}{{ snippet('slider', { slider: found, label: settings.heading }) }}{% endif %}
Result: The slider the business picked, with its effect, arrows and dots as set in Website › Slider.
form
Returns a form from the form builder (by id or web address) with its fields, or nothing. Print it with the shipped form snippet; the snippet sends the answers for you.
{% set built = form(settings.form) %}
{% if built %}{{ snippet('form', { form: built, button_label: settings.button_label }) }}{% endif %}
Result: The form the business picked in the section (for example "Contact us"), with its fields and a send button. The answers arrive in the form builder.
section
Lists the sections of your theme: section('all') returns each section's id (its file name) and title.
<ul>{% for item in section('all') %}<li>{{ item.title }}</li>{% endfor %}</ul>
Result: A list of the section names of your theme, such as "Hero", "Services", "Promotion".
current_contact
Returns the signed-in customer (name, email, mobile …), or nothing for a visitor who is not signed in.
{% set me = current_contact() %}
{% if me %}<p>{{ t('account.hello', 'Hello') }}, {{ me.name }}</p>{% else %}<a href="{{ route_signin() }}">{{ t('account.sign_in', 'Sign in') }}</a>{% endif %}
Result: "Hello, Rahim" for a signed-in customer, a Sign in link for everyone else.
booking
Returns the booking types the business offers online (name, details, url), or one type with its resources when you pass its id or web address. Returns nothing while online booking is off.
{% for type in booking() ?? [] %}<a class="btn" href="{{ type.url }}">{{ type.name }}</a>{% endfor %}
Result: One button per booking type, for example Doctor Appointment, that opens online booking.
route_ links
Functions that return the address of a storefront page in the visitor's language: route_home(), route_products(), route_blogs(), route_cart(), route_checkout(), route_signin(), route_signup(), route_my_account(), route_password_forgot(), route_password_reset(). route_search_from() is the address a search form sends to; route_checkout_from() is the address the checkout sends to.
<form action="{{ route_search_from() }}" method="get" role="search">
<input type="search" name="search" aria-label="{{ t('general.search', 'Search') }}">
</form>
<a href="{{ route_cart() }}">{{ t('nav.cart', 'Cart') }}</a>
Result: A search box that opens the products page with the matching products, and a link to the cart.
asset_url
Returns the address of a file in your theme's assets/ folder. Give the path inside assets/.
<link rel="stylesheet" href="{{ 'css/theme.css'|asset_url }}">
<img src="{{ 'img/thumbnail.svg'|asset_url }}" alt="{{ shop('name') }}">
Result: The page loads assets/css/theme.css and shows assets/img/thumbnail.svg.
media_url, img_url, image_url
Return the address of a business file (a picture from the File Manager or another upload). The three names do the same. For a media setting, media() does the same and can also ask for a smaller copy.
{% if settings.image %}<img src="{{ settings.image|media_url }}" alt="{{ settings.image_alt }}">{% endif %}
Result: The picture chosen in the section's Image setting.
link_to_product, link_to_category, link_to_brand, link_to_page, link_to_blog
Turn an id or web address into the address of that page in the visitor's language.
{% for post in get_blog('limit:3') %}<a href="{{ post.id|link_to_blog }}">{{ post.name }}</a>{% endfor %}
Result: Three links, each to its blog post page.
number_format, number_to_word, number_to_word_bn
|number_format formats a number as an amount with the currency symbol (empty for 0). |number_to_word writes an amount in English words, |number_to_word_bn in Bangla words.
{{ 1250|number_format }}
{{ 1200|number_to_word }}
{{ 1200|number_to_word_bn }}
Result: "1,250.00 ৳", "ONE THOUSAND TWO HUNDRED TAKA ONLY" and "এক হাজার দুই শো টাকা মাত্র" for a business that uses taka.
number_or_percentage
Shows a discount as it was given: a value with % stays a percentage, a number becomes an amount.
{{ number_or_percentage(product.discount) }}
Result: "15%" for a 15% discount, "50.00 ৳" for a fixed discount of 50.
now
Returns today's date or time in the format you give (Y year, m month, d day, H:i time).
<p>© {{ now('Y') }} {{ shop('name') }}</p>
Result: "© 2026 Rahim Traders".
share_to
Returns the address of the current page, or the address you pass as the fourth argument. Use it to build share links.
<a href="https://wa.me/?text={{ share_to()|url_encode }}" target="_blank" rel="noopener">WhatsApp</a>
Result: A WhatsApp link that shares the page the visitor is on.
is_app
Returns whether the page is open inside a Sylloo app: is_app() for any app, is_app('_android'), is_app('_ios') or is_app('_windows') for one.
{% if not is_app() %}{{ group('footer') }}{% endif %}
Result: The footer shows on the website but not inside the app.
global_css, global_js, csrf_token, csrf_field
{{ header }} already prints global_css() and global_js() (Sylloo's styles and the cart, sign-in and form scripts); call them yourself only in a layout without {{ header }}. csrf_token() returns the page's security code and csrf_field() prints it as a hidden form field. The built-in stores send it for you; you need it only for a script of your own.
<meta name="csrf-token" content="{{ csrf_token() }}">
Result: The page carries its security code, so a script of your own can send it with a request.
Twig tags and filters you can use
Tags: if / elseif / else, for, while, break, continue, set, do, macro, import, from, use, extends, block, include, embed, with, apply, filter, autoescape, spaceless, verbatim. Functions: range, cycle, date, max, min, random, include, block, parent, attribute. include, extends and embed read only files of your own theme. Filters: capitalize, lower, upper, title, trim, striptags, escape/e, nl2br, url_encode, format, default, first, last, length, join, keys, merge, reverse, slice, sort, batch, abs, json_encode, and raw (only on page.content, blog.content and product.description). Not available: the date filter, replace, split, round, map, filter and reduce.
{% for row in get_products('limit:6')|batch(3) %}
<div class="row">{% for product in row %}<span>{{ product.name|upper }}</span>{% endfor %}</div>
{% endfor %}
Result: Six product names in capitals, in two rows of three.
Built-in stores for cart, checkout, sign in and forms
The cart, checkout, sign-in, sign-up and contact form never send a form of their own. They use the website's built-in stores, which {{ header }} loads: $store.carts (items, cart_quantity, cart_subtotal, cart_discount, cart_vat, cart_total, isLoading, addToCart(id, qty)), $store.checkout, $store.signin, $store.signup and $store.contactUs (form, error(), isLoading, submit()). Inside such JavaScript text, print Twig values with |e('js').
<button type="button" x-data :disabled="$store.carts.isLoading" x-on:click="$store.carts.addToCart('{{ product.id|e('js') }}', 1)">
{{ t('product.add_to_cart', 'Add to cart') }}
</button>
<span x-data x-text="$store.carts.cart_quantity"></span>
Result: A click adds one piece of the product to the cart, and the number next to the cart icon goes up at once.
How to extend
- Start from a shipped section: copy the closest section of the theme you started from and change one thing at a time.
- Add a setting for every choice: when your template needs a menu, slider, form, picture or product list, add a setting of that type (
menu,slider,form,media,product_list) and read it with the matching function. - Put repeated items in blocks: slides, team members or logos are blocks with a
max, read with{% for block in section.blocks %}. - Add fixed words to the locale files: every new
t('key', 'Default')key goes intolocale/en.json,locale/bn.jsonandlocale/fi.json.
Rules and pitfalls
- Check for empty values: wrap optional parts in
{% if ... %}, so an empty setting prints nothing instead of an empty box. - Lists are limited: list functions return at most 100 records; use
limit:to ask for fewer. rawonly for business text: never put|rawon a setting, a search word or anything a visitor typed.- Fixed words in locale files: every
t()key exists inlocale/en.json, and inbn.jsonandfi.jsonwhen the business uses those languages. - No outside scripts or fonts: themes use their own
assets/files only.
Common questions
Why does my function print nothing?
It returned an empty value: the setting is not filled yet, the record is not active, or the argument has a typing error (an unknown argument is ignored). Check the value in the preview with a simple {{ ... }}.
What is the difference between settings.heading and settings('heading')?
settings.heading is a setting of the current section. settings('heading') reads a theme setting from config/settings_schema.json.
Can I use the date filter?
No. Use now('Y') for today's date, and the dates Sylloo already formats, such as product.created_at.