Creating a Custom Site Definition Attribute


Brandon Bruno


July 28, 2020


Creating a Custom Site Definition Attribute

Sometimes you may need to store a site-specific configuration setting. While there are plenty of ways to create and access configuration in Sitecore, storing a site-specific setting right on the site definition config might make the most sense (especially if it's a very high-level setting).

It may not always be best practice, but I've found it to make sense for a few recent projects. Accessing custom attributes on a site definition node is super-simple and requires no custom code.

A custom site definition attribute (simplified for clarity):

<site name="Blaze" 


To access that value in code, use the Site.Properties collection:

string settingValue = Sitecore.Context.Site.Properties["customSetting"];

Do you have questions, comments, or corrections for this post? Find me on Twitter: @BrandonMBruno