Refactoring Sitecore Templates without Losing Data

I've been maintaining a Sitecore framework that handles a number of common features: Meta Tags, Social Tags, Redirection, White Listing etc. To make it easier for site administrators to manage this configuration, I store configuration settings for each of these features in a single item, called "Site Configuration".

Unfortunately, I implemented all the fields in separate sections of the template for "Site Configuration", so after time this became a pretty monolithic template, and I was scared to refactor because I had a number of sites dependent on it and didn't want to have to try to reconfigure everything just to clean up dependency management.

Looking at the tree, I wondered whether I could create new templates for each settings section and then just move them to the new template. Turns out this worked and I was able to refactor the template quickly and painlessly. Here are the steps that worked:

  • Create a new Template for each template settings section. I ended up creating templates for each sections, but coupled multiple sections into a single template when it made sense.
  • Configure the original template to inherit each of your empty templates.
  • Expand the sections under the original template and right click each section and select Copy > Move To and use the wizard to move them under the template you created for them.  

The nice thing about this process, is that not only do the field values not get lost and you don't have to reconfigure each template, but it even preserves the field and section order of the original template since the sort order fields are moved as well.

 

An Overview of the Sitecore Data Exchange Framework

An Overview of the Sitecore Data Exchange Framework

Store your Sitecore Session in SQL instead of Mongo DB