Basker Docs

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

CategoryExamplesAccess pattern
Global functionstenant(), navigation(), settings()Call with parentheses: {{ tenant().name }}
Collection dropsall_events, all_pages, all_venuesProperty access by slug or ID: {{ all_events.hamlet }}
Document contextpage, event, postDirect 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.

PropertyTypeDescription
idstringTenant ID
namestringDisplay name
slugstringURL-safe identifier
<p>&copy; {{ 'now' | date: '%Y' }} {{ tenant().name }}</p>

Returns: Array of page nodes — the navigation tree built from published pages where showInNavigation is enabled.

Property per nodeTypeDescription
titlestringPage title
slugstringPage slug
relativePathstringFull URL path (e.g. /whats-on/events)
descriptionstringPage description
imageobjectAssociated image
childrenarrayChild page nodes
has_childrenbooleanWhether child pages exist
parentobjectParent page node
siblingsarraySibling 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).

PropertyTypeDescription
titlestringAnnouncement title
messagebooleanWhether a message exists
message_htmlstringRendered HTML of the message
targetingModestringOne 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.

PropertyTypeDescription
urlstringFull request URL including protocol and host
pathstringURL path (e.g. /events/hamlet)
methodstringHTTP method (e.g. GET)
{% assign req = request() %}
<link rel="canonical" href="{{ req.url }}">

site()

Returns: Object — site root URL.

PropertyTypeDescription
urlstringAbsolute 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:

  1. Lookup by slug or ID: {{ all_events.hamlet }} returns a single document.
  2. 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.

DropCollectionLookup fields
all_eventseventsslug
all_venuesvenuesslug
all_blogsblogsslug
all_categoriescategoriesslug
all_organizationsorganizationsslug
all_pagespagesslug, relativePath
all_peoplepeopleslug
all_postspostsslug
all_seasonsseasonsslug
all_seriesseriesslug
all_tagstagsslug
all_worksworksslug

Lookup example:

{% assign venue = all_venues.main-auditorium %}
{% if venue %}
  <p>{{ venue.title }} &mdash; {{ venue.capacity }} seats</p>
{% endif %}

Pagination query parameters control list output via URL query:

ParameterTypeDefaultDescription
all_events_limitnumber50Documents per page (max 50)
all_events_pagenumber1Page 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:

PropertyTypeDescription
field_namebooleantrue if the field has content
field_name_htmlstringRendered 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.

PropertyTypeDescription
idstringBlock instance ID
blockTypestringThe block type name (theme block name for custom blocks)
themeBlockstringOriginal theme block identifier
All field namesmixedFlattened 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()

On this page