Where variables work
| Place | What it can use |
Theme templates: layout.html, home.html, <page>.html, 404.html, 500.html, maintenance.html, collection templates | Every variable on this page that applies to it (the shared ones everywhere, the page-specific ones on their page), with the full template syntax below |
| Page text written in Admin > Pages (and home page sections) | Only the five site details in Site details in page text, plus the embed codes. Editor content is never run through the template engine |
Widget templates (widgets/<type>/index.html) | Their own fields only, with a smaller syntax: see How to create a widget |
Template syntax
| Write | Does |
{{ site.title }} | Shows a value, escaped (safe for any text). Dotted names reach inside objects. |
{{{ page.content }}} | Shows a value as HTML, not escaped. Only for HTML you trust (page content, rendered collections). |
{{#if isLoggedIn}} ... {{else}} ... {{/if}} | Shows a part only when the value is set (not empty, not zero, not false). {{#unless x}} is the opposite. |
{{#if (eq site.theme 'c3')}} | Compares two values; each side is a variable or a quoted text. No other expressions exist. |
{{#each siteNavItems}} ... {{/each}} | Repeats for every item of a list. Inside: the item's fields by name, {{ this }} (the item itself), @index, @first, @last. |
Templates are filled in once: a value that contains {{ ... }} is shown as written, never filled in again.
On every page
The site
| Variable | Value |
{{ site.title }} | The active site's title (Admin > Sites) |
{{ site.tagline }} | Its tagline, as entered (empty when none): for the hero and the footer |
{{ site.description }} | The page's description for search engines (<meta name="description">): the page's own Meta Description, else Settings > SEO > Default description, else the tagline |
{{ site.url }} | The site's address (APP_URL), e.g. https://example.com |
{{ site.year }} | The current year, e.g. for © {{ site.year }} |
{{ site.email }} | The site's Contact form email (Admin > Sites), as entered; empty when none. Never the admin notification email from Settings > General, which stays internal |
{{ site.theme }}, {{ siteTheme }} | The theme's folder name, for its files: /themes/{{ siteTheme }}/css/style.css |
{{ currentSite.name }}, .title, .tagline, .contact_email, .theme, .is_default | The active site's record from Admin > Sites |
{{#each sites}} | Every site, with the same fields as currentSite |
{{#if maintenanceMode}} | Maintenance mode is on (visitors see maintenance.html; staff still see the site). Only while the Maintenance module is enabled |
{{#if statsEnabled}} | Visitor statistics are on (Statistics module) |
The menu
| Variable | Value |
{{#each siteNavItems}} | The menu, in order: Home (and About / Contact when the theme has those pages), links from enabled modules (e.g. Products), then the pages with Show in navigation, by their navigation order |
{{ label }}, {{ path }} | Inside the loop: the link text (the page's Navigation Label, else its title) and address (/about, /#about for a home page section, the target for a Redirect page) |
{{#if isActive}} | Inside the loop: the link is the page being shown |
<nav>
{{#each siteNavItems}}
<a href="{{ path }}" class="nav-item {{#if isActive}}active{{/if}}">{{ label }}</a>
{{/each}}
</nav>
The visitor
| Variable | Value |
{{#if isLoggedIn}} | Someone is signed in |
{{ user.name }}, {{ user.email }}, {{ user.role }}, {{ user.initials }} | The signed-in person (role: admin, manager, editor or user; initials: the first two letters of the name). Empty for visitors |
{{#if isAdmin}}, {{#if isStaff}} | Signed in as an administrator; as any staff member (administrator, manager, editor) |
{{#if can.pages.edit}} | The person's permissions, can.<area>.<action> (actions view, create, edit, delete, publish; see Roles & permissions). For an "Edit this page" link, for example |
{{ currentPath }} | The address of the page being shown, e.g. /about |
{{ lang }} | The language the page is shown in, for <html lang="{{ lang }}"> |
{{ t.common.login }} | Translated text from locales/<lang>.json (t.<group>.<key>) |
{{ csrfToken }} | The token a form or script sends with a change (a _csrf field or the x-csrf-token header). Layouts also set window.__CSRF_TOKEN__ from it |
Signed-in people are never served a cached page, so these are always theirs.
On particular pages
| Template | Extra variables |
home.html | {{#each homeSections}}: the pages set to "Section of the home page", in menu order, each with slug, title, label (its Navigation Label, else the title), description (its Meta Description) and content (HTML: {{{ content }}}). Link to one as /#{{ slug }} |
| A page from Admin > Pages | page.title, page.slug, page.content (HTML), page.meta_title, page.meta_description, page.share_image, page.created_at, page.updated_at. The page template shows only {{{ page.content }}} |
500.html | {{ errorMessage }} and {{ stack }}, only with APP_ENV=development (never shown on a live server) |
maintenance.html | {{ maintenanceMessage }} (Settings > Maintenance) and {{ maintenanceUntil }} (the expected end, formatted; empty when not set or past) |
The product catalog (/products) | {{#each products}} with each product's title, slug, description, price, formattedPrice, stock, category, listing_image (the 640px-wide picture), image_alt, featured; currency; pagination.show, .page, .lastPage, .prevUrl, .nextUrl |
A product page (/products/<slug>) | product.title, .description, .formattedPrice, .stock, .category, .image_url, .image_alt, .meta_description and the other columns |
| Collection list, item and embed templates | collection (name, slug, description, url), items or item with every field by its key and the extras (<key>_formatted, <key>_stars, <key>_alt ...), pagination, the details rows. Listed in full in How to create a collection |
A theme page served by a site's init.ts route | Whatever the route's handler returns, by name (see How to create a site) |
Site details in page text
Editors can type these in a page (Admin > Pages), a home page section, or a widget placed in a page; the site shows the value, escaped:
| Type | Shows |
{{ site.title }} | The site's title |
{{ site.tagline }} | Its tagline |
{{ site.url }} | The site's address |
{{ site.year }} | The current year |
{{ site.email }} | The site's Contact form email (Admin > Sites), as plain text; nothing when the site has none (never the internal admin email). An address shown on a page can be collected by spam bots: the contact form avoids that |
Only these five: anything else in {{ ... }} stays as typed, because page text could otherwise show the signed-in person's details or the security token. Inside a code sample (<code>, <pre>) they stay as typed too, so a page can show them as an example.
Embed codes
In page text and in theme templates alike:
| Code | Puts in |
{{ widgets:render type="card" instance_name="hero" }} or [[card, hero]] | A widget (Admin > Widgets); see How to create a widget |
{{ collections:render collection="testimonials" limit="4" }} | A collection's items; see How to create a collection |
{{ page='about-us' }} | Another page's content |
{{ <module>:<name> ... }} | Anything a module offers this way; see How to create a module |
Layout slots
Not variables but places in layout.html that are filled in for each page:
| Slot | Gets |
<!-- @content --> | The page |
<!-- @title --> | The page title for the browser tab (inside <title>) |
<!-- @head --> | The canonical address, sharing and search tags, structured data, analytics |
<!-- @styles -->, <!-- @scripts --> | The CSS and JavaScript of the widgets on the page |