Automate your Episerver site definitions

We’ve all been there. Restoring a copy of the production database on your development or test-environment, start the site and you get a 404. Argh, I forgot to set the correct  site definitions! Again!

Fig 1. The freaking site definitions

In a multi site environment you can have a lot of different site definitions, and it can take quite a while to update them all manually. So, I created a small initialization module that makes sure the site definitions are correct for the current environment.

This initialization module update the site definitions for the local development machine only, but it could easily be extended to any environment you might have. I’m checking the database connectionstring to see what environment we’re on, but you can of course use e.g. a setting in web.config, or check what domain is used.

At time of writing I was using Episerver CMS 11.3

2 thoughts on “Automate your Episerver site definitions

  1. I remember the good old days, when the site definitions were settings in the Episerver.config file. Then, at one point, Episerver decided to move these into the database, and I thought “why? won’t that just be more haslse?”… And now you have come up with a solution to – eh – move these back to the config settings, where (in my opinion) they truly belong! Thanks, I’ll be using your code… 🙂

    • Thanks Anders! But I’m not sure I agree that the site definitions should be in a config file. It’s a quite powerful feature that an administrator can add a new site without the need for a new deploy.

Leave a Reply