Quick start
This page walks through a minimal working example: rendering the header
CType with a Handlebars template.
-
Include the site set
Add the
cpsit/site set to your site configuration (see Site sets):handlebars config/sites/<my-site>/config.yamldependencies: - cpsit/handlebarsCopied! -
Configure template paths
Declare where your
.hbsfiles are located using the site settings provided by the site set:config/sites/<my-site>/settings.yamlhandlebars.view.templateRootPath: 'EXT:my_sitepackage/Resources/Private/Templates/Handlebars' handlebars.view.partialRootPath: 'EXT:my_sitepackage/Resources/Private/Partials/Handlebars'Copied!See also
Template paths — all configuration methods and their priority order.
-
Create a Handlebars template
Create the template file at the path declared above. The filename without the
.hbsextension is used as thetemplate:Name EXT:my_sitepackage/Resources/Private/Templates/Handlebars/Header.hbs<div class="ce-header"> {{#if header}} <h1 class="ce-header__title">{{header}}</h1> {{/if}} {{#if subheader}} <p class="ce-header__subtitle">{{subheader}}</p> {{/if}} </div>Copied! -
Configure the content element
Point the
headerCType at the template using aHANDLEBARSTEMPLATEcontent object:tt_content.header = HANDLEBARSTEMPLATE tt_content.header { templateName = Header variables { header = TEXT header.field = header subheader = TEXT subheader.field = subheader } }Copied!Each entry in
variablesis processed as a TYPO3 content object against the current content element record. The resulting values are passed to the template alongside the automatically injecteddataandcurrentvariables. -
Flush caches
After editing TypoScript, flush the TYPO3 page cache. After editing
Services., flush and rebuild the service container as well.yaml
Next steps
- HANDLEBARSTEMPLATE content object — complete reference for all
HANDLEBARSTEMPLATEproperties - Writing templates — template names, partials, layouts and built-in helpers
- Data processors — enrich templates with database queries, menus, and custom variable processing
- Custom helpers — expose custom PHP logic to templates