2 min read

Sitecore Basics - layouts on branches

Hi all, we're back with a blog post about some Sitecore basics.

For a customer I was working on I noticed that there was no layout defined on the standard values of the page templates they were using.

All layout was defined either on the items created from the template or on the several branches that they created.

Both functionalities have their own advantages and work rather good together as well. This blog post is meant to show how both layouts work together and will highlight a drawback as well.

The gist

You define a layout on the standard values of a template because you want that layout to be applied for ALL items that get created of that template!

You define a layout on the branch if you want that layout to be applied for ALL items that get created of that branch!

Wait... isn't that the exact same thing?
Yes but no 😄

Layout on a branch will be copied to the created items.
This means that when you add additional renderings in your branch, existing items created from that branch will not get those new renderings.
Only newly created items from the branch will get them.

This is different from the behaviour of the layout on the standard values. When you add a rendering there, it will be on all items created.

From the Sitecore documentation

The Sitecore documentation with this information can be found here:
https://doc.sitecore.com/xp/en/developers/latest/sitecore-experience-manager/branch-templates.html

"Unlike standard values, which Sitecore stores in a single standard values item for each data template and applies to all items based on that template that do not have values for those fields, Sitecore duplicates field values within branch template definition items to each item created using that branch template."

Reason for this blog post

We had to change the template of several pages to get back to a certain base line and remove some overengineering on them (imagine a project with 20 templates all called Content Page).
One of the concerns was that we didn't want to lose the layout of our pages. Luckily for us, the layout wasn't fetched from the standard values since there was none.

How to test yourself

  • create a template with a layout in the standard values
  • create a branch that uses that template
  • create an item created from that branch
  • update the layout on standard values > the item has the layout change!
  • update the layout on the branch > the item doesn't have the layout change!