Template context
Every variable, global function, and collection drop available in Liquid templates rendered by Basker
This reference documents every variable and function available in Liquid templates rendered by Basker. Entries are grouped into global functions, collection drops, and data flattening behaviour.
Overview
| Category | Examples | Access pattern |
|---|---|---|
| Global functions | tenant(), navigation(), settings() | Call with parentheses: {{ tenant().name }} |
| Collection drops | all_events, all_pages, all_venues | Property access by slug or ID: {{ all_events.hamlet }} |
| Document context | page, event, post | Direct property access on the current document variable |
Global functions
Callable from any template or layout. Return data scoped to the current tenant and request.
tenant()
Returns: Object — the current tenant.
| Property | Type | Description |
|---|---|---|
id | string | Tenant ID |
name | string | Display name |
slug | string | URL-safe identifier |
<p>© {{ 'now' | date: '%Y' }} {{ tenant().name }}</p>navigation()
Returns: Array of page nodes — the navigation tree built from published pages where showInNavigation is enabled.
| Property per node | Type | Description |
|---|---|---|
title | string | Page title |
slug | string | Page slug |
relativePath | string | Full URL path (e.g. /whats-on/events) |
description | string | Page description |
image | object | Associated image |
children | array | Child page nodes |
has_children | boolean | Whether child pages exist |
parent | object | Parent page node |
siblings | array | Sibling page nodes at the same level |
{% assign nav = navigation() %}
<ul>
{% for item in nav %}
<li><a href="{{ item.relativePath }}">{{ item.title }}</a></li>
{% endfor %}
</ul>announcements()
Returns: Array of announcements targeted to the current page. Filtered automatically by their targeting mode (all pages, specific collection, specific pages, URL pattern).
| Property | Type | Description |
|---|---|---|
title | string | Announcement title |
message | boolean | Whether a message exists |
message_html | string | Rendered HTML of the message |
targetingMode | string | One of all, collection, pages, simple |
{% assign alerts = announcements() %}
{% for alert in alerts %}
<div class="announcement" role="alert">
{{ alert.message_html }}
</div>
{% endfor %}all_forms()
Returns: Object indexed by form ID and slug. All forms for the current tenant.
{% assign forms = all_forms() %}
{% assign contact_form = forms['contact-us'] %}
{% if contact_form %}
<p>{{ contact_form.title }}</p>
{% endif %}apps()
Returns: Object — app configuration data for the current tenant, keyed by app handle. Only fields marked visible to the live site are included.
{% assign app_config = apps() %}
{% if app_config.google.analyticsId %}
<script async src="https://www.googletagmanager.com/gtag/js?id={{ app_config.google.analyticsId }}"></script>
{% endif %}settings()
Returns: Object — theme settings defined in config/settings_schema.json and configured in the admin. Flat object with field names as keys.
{% assign theme = settings() %}
{% if theme.logo %}
<img src="{{ theme.logo | image_url: width: 200 }}" alt="{{ tenant().name }}">
{% else %}
<span class="site-title">{{ tenant().name }}</span>
{% endif %}attribute_definition()
Returns: Object nested by namespace and key. Custom attribute definitions configured for the tenant.
{% assign attrs = attribute_definition() %}
{% assign genre_attr = attrs.genre.name %}body_classes()
Returns: String — CSS class names derived from the current template path. For templates/event.featured.liquid, returns "page page-featured".
<body class="{{ body_classes() }}">content_for_header
Returns: String (HTML) — system-injected content for the <head>: preconnect hints, generator meta tag, and preview-mode scripts when active.
<head>
{{ content_for_header }}
</head>forms_endpoint()
Returns: String (URL) — the base URL for the forms submission service. Used internally by {% form %}; available for custom form implementations.
<form method="POST" action="{{ forms_endpoint() }}/forms/{{ form_id }}">
...
</form>request()
Returns: Object — information about the current HTTP request.
| Property | Type | Description |
|---|---|---|
url | string | Full request URL including protocol and host |
path | string | URL path (e.g. /events/hamlet) |
method | string | HTTP method (e.g. GET) |
{% assign req = request() %}
<link rel="canonical" href="{{ req.url }}">site()
Returns: Object — site root URL.
| Property | Type | Description |
|---|---|---|
url | string | Absolute root URL (e.g. https://northgatearts.com) |
locale()
Returns: String — the current locale code (e.g. en, cy, fr).
<html lang="{{ locale() }}">is_preview()
Returns: Boolean — whether the current request is in preview mode.
{% if is_preview() %}
<div class="preview-badge">Preview Mode</div>
{% endif %}defaultLayout
Returns: Object or null — the default layout document for the current tenant.
{% if defaultLayout %}
<p>Layout: {{ defaultLayout.title }}</p>
{% endif %}Collection drops
Collection drops provide access to all documents of a given collection. Each supports two access patterns:
- Lookup by slug or ID:
{{ all_events.hamlet }}returns a single document. - List iteration: with pagination query parameters (
all_events_limit,all_events_page).
Lookups are lazy-loaded and cached per request. A maximum of 20 unique lookups per drop per request is enforced.
| Drop | Collection | Lookup fields |
|---|---|---|
all_events | events | slug |
all_venues | venues | slug |
all_blogs | blogs | slug |
all_categories | categories | slug |
all_organizations | organizations | slug |
all_pages | pages | slug, relativePath |
all_people | people | slug |
all_posts | posts | slug |
all_seasons | seasons | slug |
all_series | series | slug |
all_tags | tags | slug |
all_works | works | slug |
Lookup example:
{% assign venue = all_venues.main-auditorium %}
{% if venue %}
<p>{{ venue.title }} — {{ venue.capacity }} seats</p>
{% endif %}Pagination query parameters control list output via URL query:
| Parameter | Type | Default | Description |
|---|---|---|---|
all_events_limit | number | 50 | Documents per page (max 50) |
all_events_page | number | 1 | Page number |
Replace all_events with the relevant drop name (all_venues_limit, all_posts_page, etc.).
Data flattening behaviour
Document data is automatically flattened before it reaches Liquid templates. Understanding these transformations matters for accessing data correctly.
Relationships
Relationship fields are unwrapped. A __collection hint is added to identify the source collection.
Before flattening:
{
"venue": {
"relationTo": "venues",
"value": { "id": "abc123", "title": "Main Auditorium", "slug": "main-auditorium" }
}
}After flattening (what your template sees):
{
"venue": {
"id": "abc123",
"title": "Main Auditorium",
"slug": "main-auditorium",
"__collection": "venues"
}
}Access:
{{ event.venue.title }}
{{ event.venue.__collection }}Rich text fields
Rich text fields are split into two properties:
| Property | Type | Description |
|---|---|---|
field_name | boolean | true if the field has content |
field_name_html | string | Rendered HTML string |
{% if event.description %}
<div class="rich-text">
{{ event.description_html }}
</div>
{% endif %}For more on rendering rich text in themes, see Field types reference.
Blocks
Block data within documents is flattened to include id, blockType, and all field data at the top level.
| Property | Type | Description |
|---|---|---|
id | string | Block instance ID |
blockType | string | The block type name (theme block name for custom blocks) |
themeBlock | string | Original theme block identifier |
| All field names | mixed | Flattened field values from the block schema |
Tenant field removal
The tenant field is automatically stripped from all document data, recursively. This prevents accidental exposure of tenant configuration in templates.
Theme settings on documents
When a document has per-document theme settings, they're available as:
{{ page.theme.settings.field_name }}Theme settings are flattened from the raw themeSettings array into a theme.settings object.
Index
Tenant and site: tenant(), site(), locale()
Navigation and pages: navigation(), all_pages
Content collections: all_events, all_venues, all_blogs, all_posts, all_people, all_organizations, all_seasons, all_series, all_works, all_categories, all_tags
Forms and announcements: all_forms(), announcements(), forms_endpoint()
Theme and layout: settings(), body_classes(), content_for_header, defaultLayout, apps(), attribute_definition()
Request context: request(), is_preview()
Related
- Writing templates — using context variables in templates.
- Writing layouts — using global functions in layouts.
- Rendering blocks — block rendering context.