Add and extend an SXA template

Current version: 10.2

Templates are preset schemas for content items that are used to base new items on instead of recreating the specific fields of a new item every time. You might want to add a data template when, for example, a project requires fields that are not defined in existing data templates, or when new items require unique default field values or default settings (for example, a default workflow).

Important

We recommend not to change the _Standard values of predefined SXA templates. To avoid Experience Editor issues, it is better to create your own template and inherit from an SXA template.

Once you create a tenant, SXA will create a tenant templates location for you in a Project folder. You can add new templates for specific projects in that same folder. This may be convenient if you are working on a project that needs custom templates. You can add your project templates to: /sitecore/templates/Project/

Note

We strongly recommend that you adhere to the Helix guidelines. Helix offers a set of official guidelines and recommended practices for Sitecore development.

SXA validates items by checking an item's template inheritance instead of template name or template ID. This makes it possible for you to create and/or extend a template without breaking anything.

Create an SXA template

To add a template:

  1. In the Content Editor, navigate to your tenant templates folder (sitecore/Templates/Project/). For example, to add a custom template to your new project, go to: /sitecore/templates/Project/<projectname>.

    Important

    Never put custom templates in SXA-controlled branches because SXA overwrites these during SXA updates. For example, you can place templates in folders that are siblings of the Experience Accelerator folder but not inside.

  2. Right-click the item and click Insert, New Template. Alternatively, click NewTemplate in the Options section.

  3. Enter a name for the new template, select a base template, and click Next. For example, templates for items that represent a page need to inherit from the default Page template.

    Note

    Although it is not required to follow SXA naming conventions, you might find it useful as it clearly defines how a particular template can be used. In SXA, template names that cannot be used to create items but can function as base templates for other templates are prefixed with an underscore. For example: _Searchable, _Designable, _Sticky Note.

  4. To add additional base templates to your template when they define standard fields that you want your new template to inherit, click the template and on the Content tab, in the Data section, double-click the template you want to add, or use the arrow to add it.

  5. On the Builder tab, in the Add a new section field, add the relevant data template fields, for example, Data.

    Note

    To assign default values to fields in your template, on the Options tab, click Standard values. With each new item created from that template, fields will inherit values from the corresponding field in the standard values item.

  6. Save your changes.

Extend an SXA template

You can extend an existing SXA template. Templates can consist of many base templates.

Note

You must make sure that you do not break the template inheritance. You can see the inheritance structure of the template in the Content Editor, on the Inheritance tab of the template.

To extend an existing SXA Project template with your custom template:

  1. In the Content Editor, click the template that you want to extend.

  2. On the Content tab, in the Data section, double-click the template you want to add and move it to the Selected section using the arrow.

Note

If the SXA template that you want to extend does not exist in your Project templates folder yet, it is better to create a new Project template and use the Base template field to add the template that you want to extend as well as the custom base template that you added.

Do you have some feedback for us?

If you have suggestions for improving this article,