Proper way to patch Sitecore configs

This will be a quick post.  While helping a team member, I was reminded there’s two ways to patch Sitecore configs:

  1. Simply repeating the XML node to a config file in the Include folder:
    <setting name="AllowLogoutOfAllUsers" value="false"/>
    
  2. Following the pattern shown in the SitecoreSettings.config.example that comes with every config file:
    <setting name="AllowLogoutOfAllUsers">
    <patch:attribute name="value">false</patch:attribute>
    </setting>
    

If you go with approach 1, your setting override will work but you’ll get multiple instances of the setting in the /sitecore/admin/showconfig.aspx page – one for each instance of the setting coming from a config file.  The last instance of the setting on /sitecore/admin/showconfig.aspx is the one that will be used by Sitecore.  This approach is appropriate for adding new settings.

If you go with approach 2, Sitecore will find the single instance of the setting and will simply change it’s value.  This is the proper way to change an existing setting.

Leave a Reply