How to Create Branch Templates in Sitecore CMS
February 17, 2015
This is the 20th post in our series about learning how to use and develop for Sitecore CMS, and the follow-up post to “How to Configure Insert Options in Sitecore CMS”.
In this post, I cover how to create a branch template in Sitecore CMS. Branch templates can be used to build reusable collections of items, or even hierarchies of items. They are very useful when you want to implement similar structures in a number of places. This is particularly useful when building out new sites in a multi-site solution, or when creating content trees that have a consistent, repetitive structure.
Building the templates
This example will cover building a branch template for a multi-site solution. Before I jump into creating the branch template, it would be helpful to have a variety of templates to build with.
Create the following templates in
- Home Page
- Website Settings
For purposes of this example, no fields will be added to the templates, however icons have been set so that the types are easy to distinguish.
These templates will form our basic site structure. A website will contain a home page and settings item. The home page will contain an about page, contact page, and error page.
The tree will appear as:
Building the Branch Template
/sitecore/templates/Branches/User Defined folder in the content tree.
Create a “New Branch” using the button in the ribbon, the button in the folder, or the button in the context menu. A modal will appear where the root template item may be selected.
As the Website template is the root of the tree we’re creating, select
User Defined/Website and click the “Create” button.
A new branch template item will have been created including a Website item named
$name is a template token that will be replaced with the selected name when the branch template is used. Template tokens will be covered more at a later date.
$name item, and create new items to build out the desired tree structure.
With the items in place, our branch template is complete and ready to be inserted.
Stay up to date with our email updates!
Creating Content From a Branch Template
/sitecore/Content item and select the "Insert from Template" option in the ribbon, folder, or item's context menu.
The standard "Insert from Template" modal will appear. Select
Change the item name to
Example and click the "Insert" button in the modal.
A new Website item will have been created with the given name, along with new subitems.
Check back for the next tutorial. And, as always, if you have any questions or if there's something you'd like to see covered, tweet us!