stageblocks Tag
The stageblocks tag dynamically renders all content blocks associated with a page, event, or other content type. It’s the primary way to output block-based content in your templates.
Syntax
Section titled “Syntax”{% stageblocks content_type %}{% stageblocks content_type, blockType:template/path.liquid %}Parameters
Section titled “Parameters”| Parameter | Required | Description |
|---|---|---|
content_type | Yes | The type of content to render blocks for |
blockType:template | No | Override the default template for a specific block type |
Supported Content Types
Section titled “Supported Content Types”The stageblocks tag supports the following content types:
| Type | Description |
|---|---|
page | Standard pages |
event | Events |
series | Event series |
season | Seasons |
venue | Venues |
person | People (artists, performers, etc.) |
organization | Organizations |
work | Creative works |
post | Blog posts |
blog | Blog landing pages |
collection | Smart collections |
reusable-content | Reusable content blocks |
Basic Usage
Section titled “Basic Usage”In your template files, use stageblocks to render all blocks associated with the current content:
<main> <h1>{{ page.title }}</h1>
{% stageblocks page %}</main><article class="event"> <header> <h1>{{ event.title }}</h1> <time>{{ event.startDate | date: '%B %d, %Y' }}</time> </header>
{% stageblocks event %}</article><article class="person-profile"> <h1>{{ person.name }}</h1> {{ person.biography_html }}
{% stageblocks person %}</article>Output Structure
Section titled “Output Structure”The stageblocks tag wraps all rendered blocks in a container div:
<div class="content-blocks"> <!-- Block 1 output --> <!-- Block 2 output --> <!-- ... --></div>Each block is rendered using its corresponding template from the blocks/ directory in your theme.
Template Overrides
Section titled “Template Overrides”You can override the default template for specific block types by passing additional parameters:
{% stageblocks page, hero:blocks/hero-fullwidth.liquid %}This renders blocks of type hero using blocks/hero-fullwidth.liquid instead of the default blocks/hero.liquid.
Multiple overrides:
{% stageblocks event, hero:blocks/event-hero.liquid, cta:blocks/event-cta.liquid %}How Block Rendering Works
Section titled “How Block Rendering Works”- The tag reads the
blocksarray from the content object (e.g.,page.blocks) - For each block, it determines the block type (e.g.,
hero,feature-grid,call-to-action) - It looks for the corresponding template in
blocks/[blockType].liquid - If a template override is specified, it uses that template instead
- The block data is passed to the template as the
blockvariable
Block Data Access
Section titled “Block Data Access”Within block templates, you have access to the block object containing all the block’s field values:
{# blocks/hero.liquid #}<section id="{{ block.id }}" class="block-hero"> <h2>{{ block.heading }}</h2> <p>{{ block.description }}</p>
{% if block.image %} <img src="{{ block.image | image_url: width: 1200 }}" alt="{{ block.image.alt }}"> {% endif %}
{% if block.cta_text and block.cta_link %} <a href="{{ block.cta_link }}" class="btn">{{ block.cta_text }}</a> {% endif %}</section>Example: Complete Page Template
Section titled “Example: Complete Page Template”{# templates/page.liquid #}{% comment %} Standard page template with blocks{% endcomment %}
<main class="page-content"> {# Page header #} <header class="page-header"> <h1>{{ page.title }}</h1> {% if page.description %} <p class="lead">{{ page.description }}</p> {% endif %} </header>
{# Render all page blocks #} {% stageblocks page %}
{# Page footer with metadata #} <footer class="page-meta"> <p>Last updated: {{ page.updatedAt | date: '%B %d, %Y' }}</p> </footer></main>