Sitecore Template Inheritance Best Practices
As you will probably know it’s possible to make templates inherit from other templates - in fact when you create any new template in Sitecore, it will always inherit from the Sitecore standard template.
What’s not so obvious are the implications of inheritance. Obviously inheritance is a good thing right? It means you don’t have to define the same fields over and over and means you can update several templates/items by simply updating one template. Great. However as with inheritance in C# code, things can quickly start to get ugly if you have complicated inheritance hierarchies. For this reason I try to:
- avoid having more than two levels of inheritance, and
- split my templates into four main folders as follows:
1. System Templates
If a template is going to be the base template for other templates, make sure it is only used for this purpose. Don’t make your system templates inherit from each other. Don’t make any items use these templates directly. Used for templates which form the fields of one section of another template.
2. Data Templates
These templates should be used for system settings items e.g. items for drop-down lists, or category items to assign to other content items. i.e. data templates are for content in your site which is not a page.
3. Page Templates
These are templates for page-level content items. These should rarely need to define their own fields. Instead make these templates inherit from one or more of your system templates. Don’t be tempted to make page templates inherit from each other. It might seem like a good idea, but it reduces flexibility. It’s better to have several page templates inherit from the exact same set of system templates than to inherit from each other as this keeps your inheritance hierarchy simple.
4. Parameters Templates
Templates used to specify rendering parameters for a Sublayout or XSL rendering. These will all inherit from the sitecore standard rendering parameters template, so there should be little need for these to inherit other templates.