Short solution for short problems

How to create site definition (template) with a custom masterpage

Today I started to investigate the site definitions again.

It has been a while since I've been there, and lots of things changed since the upgrage to WSS3.0. My first challange was to create a simple site definition. No big problem there. Now I'm configuring this site definition to match the style of the company. So the first thing I had to find out was how to implement a custom masterpage in my site definition.

The masterpages definitions are found in this directory: Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\GLOBAL. By default you will find 2 masterpages, the default.master and the mwsdefault.master. So I copied the default.master and renamed it to MRD.master. This is the first thing you do. Then change some small things in the master page, so you can see if your site template implements the correct master page. Now lets look at the changes you'll have to make in the ONET.xml of the site template.

In every configuration you want to implement the custom master page, you should have set the CustomMasterUrl attribute like this:

<Configuration ID="0" Name="Default" CustomMasterUrl="_catalogs/masterpage/mrd.master">

<Configuration ID="1" Name="Blank" CustomMasterUrl="_catalogs/masterpage/mrd.master">


So once the CustomMasterUrl attribute is set , we add the masterpage module to the modules section of each configuration where the CustomMasterUrl attribute is set.


 <Module Name="Default" />

 <Module Name="MRDMasterPage" />



The last thing we have to do is declare this module on the bottom of the onet.xml, in the modules section:



 <Module Name="MRDMasterPage" Url="_catalogs/masterpage" SetupPath="global">

  <File Url="MRD.master" Type="GhostableInLibrary" IgnoreIfAlreadyExists="TRUE" />


When you look at the ONET.xml of the MPS site template, you'll find a module called: EnsureMWSMasterPage. This has the property RootWebOnly set to false, so all subsites will have the masterpage copied to them. You can use this module simular as the one I explained on top.

The next thing I'm going to find out is how we can set the theme of the site using site templates.

By the way, changing or creating site templates is not the supported way. But sometimes the only way. Microsoft is providing all kinds of alternatives for altering the site defenitions, but still its powerfull. When you change things and implement them in production, you should have a document where the changes are described in detail. So you can reporduce them after you installed an update.