Skip to main content

Inheriting Sitecore Site Properties

Recently, while poking around the Sitecore.Kernel assembly I came across a feature which allows you to inherit the properties assigned to one site into another. It's seemed like this might be useful for multi-site Sitecore implementations, but I hadn't heard of it before.

When I went back and actually looked at the comments in the web.config I found the feature is mentioned. I guess it's just one on of those things I always skipped over. Still, Google has very little to say on the subject, so I think it's worth writing about for any other developers that are to lazy to read the documentation provided ;-)

The following web.config section should be familiar to most Sitecore developers. It defines all the logical sites for your Sitecore implementation.
<sites>
  <site name="shell" virtualFolder="/sitecore/shell" 
    physicalFolder="/sitecore/shell" rootPath="/sitecore/content" 
    startItem="/home" language="en" database="core" domain="sitecore" 
    loginPage="/sitecore/login" content="master" contentStartItem="/Home" 
    enableWorkflow="true" enableAnalytics="false" analyticsDefinitions="content" 
    xmlControlPage="/sitecore/shell/default.aspx" browserTitle="Sitecore" 
    htmlCacheSize="2MB" registryCacheSize="3MB" viewStateCacheSize="200KB" 
    xslCacheSize="5MB" disableBrowserCaching="true"/>
  <site name="login" virtualFolder="/sitecore/login" 
    physicalFolder="/sitecore/login" enableAnalytics="false" database="core" 
    domain="sitecore" disableXmlControls="true"/>
  <site name="admin" virtualFolder="/sitecore/admin" 
    physicalFolder="/sitecore/admin" enableAnalytics="false" 
    domain="sitecore" loginPage="/sitecore/admin/login.aspx"/>
  <!-- etc etc ... -->
</sites>
This is quite dense stuff and as you start adding additional sites, it can begin to get a bit unwieldy. The "inherits" attribute helps with this by allowing you to specify common values once, and then just manage the exceptions.

In the example below, the definitions for site2, site3 and site4 all inherit their attribute values from site1. Site3 and Site4 also override some values by specifying them explicitly.
<sites>
  <site name="site1" virtualFolder="/sitecore/admin" 
    physicalFolder="/sitecore/admin" enableAnalytics="false" 
    domain="sitecore" loginPage="/sitecore/admin/login.aspx"/>

  <site name="site2" inherits="site1" />
  <site name="site3" inherits="site1" domain="extranet" />
  <site name="site4" inherits="site1" enableAnalytics="true" />
  <!-- etc etc ... -->
</sites>
I can't really believe that I hadn't spotted this feature before, and I'm sure many Sitecore devs use it all the time. But surely I can't be the only one who missed it...


Another article discussing Sitecore site inheritance:
Enable Multi-level Site Property Inheritance
(Please let me know if you are aware of any other related articles.)



Comments