Console
FunctionsCanopy

canopy.blocks

The canopy.blocks function renders a block area containing the Canopy Blocks managed in the Canopy editor.

{{ canopy.blocks(handle, { shared: ... }) }}
ArgumentDescriptionData Type
handleThe block area identifierString
shared (optional)Set to true to share the area's blocks across the whole siteBoolean

The function outputs every block editors have added to the area, in the order they arranged them. Each block is rendered with its own block template.

By default a block area is scoped to the current page, so the same handle holds different blocks on different pages. With shared: true the area holds one set of blocks for the whole site, which is useful for footers and other global sections.

Render specific templates

Instead of options, you can pass an array of block template names. The templates are rendered in the given order, using editor content where it exists and template defaults where it does not:

{{ canopy.blocks('showcase', ['hero', 'features', 'cta']) }}

Example

<body>
  {{ canopy.blocks('main') }}
  {{ canopy.blocks('footer', { shared: true }) }}
</body>

Last updated on

On this page