Let’s Talk

We would love to hear from you. Want to know more about
our services or have any questions? Say Hi!

What are Sitecore Templates?

December 15, 2022
What are Sitecore Templates?
Keyur Garala
Keyur Garala
Sitecore Certified Solutions Architect

In web development, a template usually refers to something that is related to the presentation. A template is usually a view, partial view, HTML page, or user control that is used to represent a type of page within the CMS. This is not the case within Sitecore.

Sitecore templates refer to a data schema that defines the data definitions for a piece of content. In Sitecore, a template has nothing to do with the presentation.


Template node in Sitecore Content Tree

Template Builder

The Template Builder is a special interface in Sitecore for creating templates. Template sections and fields are created and edited in rows. Each row is made up of the field name, data type, and source:

Types of Templates in Sitecore:

There are different types of templates in Sitecore and below they are explained in detail.

  1. Data Templates: Data template defines the data and all the information that you want to display on a page like text, image etc. Data template is schema for Sitecore content. Any content item in a Sitecore database is based on a data template. It can contain fields and can be instanced by editors using insert page. Data templates can inherit from other data templates and can be assigned Presentation Details and insert options.

    How to Create a Data Template:

    1. Navigate to Sitecore/Templates and right click on Templates and click on Template folder, it will create a folder where you can create all your templates.

    2. Navigate to the folder you have created (“Page_Templates” in my case) and create a new template by right-clicking on it.

    3. Give your template a name.

    4. Select the folder you have created and click next.

    5. Your template is created.

    6. Now create a section and fields in your template. To do that click on the builder tab of the template and just input a section name in the textbox.


    The builder columns from left to right are:

    • Name: The name of the field. This will be displayed by default to Content Authors. When referencing a template field in code, this is the name

    • Type: Data type of this field.

    • Source: A location in the content tree to use as the source of data (read: dropdowns, lists, etc.).

    • Un-versioned: Determines if this field's data will be shared across all numbered versions.

    • Shared: Fields marked as 'Shared' will update across all language versions of the Item.

    Templates in Sitecore also have the concept of sections. Sections group fields together - nothing more, nothing less.

    what-are-sitecore-templates-9 what-are-sitecore-templates-10

    These sections are reflected in the Content Editor

  2. Branch Template: A branch template consists of a branch template definition item, which can contain a single item, a hierarchy of items, or multiple hierarchies of items. It allows you to define the content structure and entire branch of templates so by creating an instance of a branch template the whole item structure appears without the user having to create them one by one.

    You do not need to create a branch template for every data template. Use branch templates when you want to:

    • Copy initial field values into a created item (rather than inheriting them from the standard values). This includes both field values for the Standard template fields (which are assigned using the ribbon controls, for example, the item’s icon or access right assignments) and fields defined in custom data templates (such as a product number).

    • Insert multiple items.

    • Assign access rights to inserted items.

    • Control which accounts can insert items using the branch template.

    • Provide content authors with the ability to create multiple items at once (either siblings or descendants). Multiple content subtrees can be created using branch templates.

    You can create any number of items within a branch template definition item, and each item can have any number of descendant items. When a user creates an item using the branch template, Sitecore replicates all descendants of the branch template definition item before expanding tokens.

    Building the Branch Template-

    Select the /sitecore/templates/Branches/User Defined folder in the content tree.

    Steps to create Branch Template:

    Scenario – Imagine you had to create a website for a big company and that company contained different department and each department had to have their own space on the website and each department must have about us page and contact us page

    1. At first navigate to “/sitecore/Templates” create a template which is the base for branch template.

    2. Now, navigate to /sitecore/Templates/Branches/User Defined and create a folder for your site.

    3. Now right click on the folder you created and click New Branch.

    4. Select the base template you created for your branch template.


      (In my case I have created Department template as a base template for my branch template)

      Note – Base template give you the same name to your branch template, you can rename it by right-clicking on it.

    5. A new branch template item will have been created including a website item named $name


      $name is a template token that will be replaced with the selected name when the branch template is used.

      A sitecore token is way to have a field value dynamically resolved during item creation

    6. Right click on $name token and click on insert from template to create branch template.

    7. Select the base template you created for your branch template, give it a name and click Insert.

    8. Now navigate to sitecore/Content/Home and right click on Home item and click insert from template.

    9. Select the branch template you created, give it a name and click insert.


      Now your complete department structure is created.

  3. Command Template: Command templates allow insert of items according to logic rather than predefined structures.

    Unlike data templates and branch templates, which consist of predefined structures, command templates reference Sitecore UI commands to invoke wizards or other logic used to create new items.

    All other template categories contain a predefined structure. But what if you need to write some dynamic logic to create items, for this we use Command templates.

    Command template define a class and method to be called during an insert operation. Whenever we try to create an item from this template, associate class method would be executed.

    We can create a command template, using /System/Branches/Command Template.

    How to start with command template-

    1. Create templates with required fields.

    2. Create a class that inherits from Sitecore.Shell.Framework.Commands.Command, and override the Execute () method.

    3. Add a /configuration/command element to the file /App_Config/Commands.config.

    4. Insert a command template definition item using /System/Branches/Command Template data template.

    5. In the command template definition item, in the Data section, for the Command field, enter the command code.

    6. Assign this command template to standard values of the template insert option created in step1.