What is Branch Template? And where do we use it?

Whenever we discuss anything around Sitecore templates, we always mention about Data template and Rendering Parameter Template which is widely used & you can read about it here but we always forget to mention about Branch & Command Template which are indeed a powerful tool provided by Sitecore to achieve certain functionality.

Lets see Branch Template in this blog.

What is Branch Template?
We can say that Branch template is a solution that Sitecore has provided for creating item hierarchies in one click. A branch template consists of a template definition item, which can contain a item, a hierarchy of items, or multiple hierarchies of items. When a user creates an item based on a branch template, Sitecore duplicates the item(s) beneath the branch template definition item, including any field values, and then performs the token substitution on item names and field values based on Standard Values.

Where can we use this template?
There are couple of scenarios where the Branch template can come handy. One of which is, you have Press Release Details page and you have a carousel & few documents on it. You always create a Press Release item and then create 2 folders under it, one for Carousel & one for documents. This hierarchy can be created as a Branch Template. While creating Press Release item create through Branch template instead of Press Release data template and by default the hierarchy will be present for you.

Lets see an example on how to create a Branch Template.

  1. We need to create Press Release data template.
    Press release data template
  2. We need to create 2 more data templates for Carousel & Documents folder, set the icons and insert options on it.
    Folder templates
  3. In normal scenario, we will set both folder templates as the insert options on Press release template. Lets do this step as well.
    Inert options
  4. Now we will go to Branch template (/sitecore/templates/Branches/User Defined), I am creating the template for demo purpose hence creating under User Defined.
  5. Right click on User Defined >> New Branch
    New Branch Template
  6. Select Press Release data template under User Defined which we created earlier and click Create.
    Template creation
  7. A branch with name Press Release under $name as child item will get created.
    Branch Template
  8. Right click on $name item and insert both the folders.
    Branch Template 1
  9. We are done with creating the Branch template, lets create an item based on this template and check if we get the hierarchy we have defined.
  10. Go to the Home item (/sitecore/content/Home) >> Right click >> Insert from template.
  11. Select the Branch template for Press Release.
    Item Creation
  12. Enter the name for the item and click Insert.
  13. The item with defined hierarchy gets created.
    PR Item

This is how we create the Branch Template. Hope this blog has cleared the concept of Branch Template and where we can use this template.

Thank you.. Keep Learning.. Keep Sitecoring.. 🙂

One thought on “What is Branch Template? And where do we use it?

  1. Pingback: Using Branch Presets to fix the static datasource path in the Branch Templates | Sitecore Diaries

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s