How to use Subtemplates
Tutorial valid only for Legacy CMS Stores.
Subtemplates are intended for small structures that could be reused in several Page Templates. Subtemplates work as “includes”.
You can create an HTML block that you intend to reuse, and then insert a call inside a Page Template. To create a subtemplate:
- In the VTEX Admin, access Storefront > Layout > CMS and go to the Templates de Página > Subtemplates folder.
- Click on the Novo Subtemplate option.
- Fill in the
Nome do Template
field. - Paste your code on the
XHTML do Template:
field. - Then, click on salvar.
In order to reference a Subtemplate inside a page Template, use the syntax below:
<vtex:template id="name-of-the-id" />
Fill in the id
attribute with the name given to the subtemplate.