Home > Uncategorized > Using a custom master page in a site definition

Using a custom master page in a site definition


Don’t use the Sharepoint Solution Generator, so far we have not been able to upgrade the site definitions through a solution without it killing existing sites based on the site definition. 

I have seen many different ways of doing this, but I found the following method seemed to work for me, using the “SharePoint Extensions for Visual Studio 2005” and the “SharePoint Solutions Generator

  • Use the “SharePoint Solution Generator” to create a site definition project.
  • Open the project and add your custom master page to the “Site Definition” folder

  • Open up “onet.xml”
  • Add the following node to the “ListTemplates” section

<ListTemplate Name=”mplibDisplayName=”$Resources:MasterPageGallery;Description=”$Resources:global_onet_mplib_desc;SetupPath=”global\lists\mplibType=”116BaseType=”1Path=”GLOBALHidden=”TRUEHiddenList=”TRUENoCrawl=”TRUEUnique=”TRUECatalog=”TRUEOnQuickLaunch=”FALSESecurityBits=”11AllowDeletion=”FALSEAllowEveryoneViewItems=”TRUEImage=”/_layouts/images/itdl.gifAlwaysIncludeContent=”TRUEDocumentTemplate=”100” />

  • Add the “MasterUrl” attribute to the “Configuration” node with a value of “_catalogs/masterpage/project.master”, where project.master is the name of your custom master page. This means all the pages using the “~masterurl/default.master” token will use the URL defined to point to your custom master page

<Configuration ID=”0Name=”DefaultMasterUrl=”_catalogs/masterpage/project.master“>

  • Add a “Module” node to the Modules section of the configuration called “MasterPage” that will reference the module definition in the “Modules” section of the onet file

<Module Name=”MasterPage” />

  • Add a module definition to the “Modules” section of the onet file. This will copy the custom master page file into the master page library when the site is provisioned.

<Module Name=”MasterPageList=”116Url=”_catalogs/masterpageRootWebOnly=”FALSE“>

<File Url=”project.masterType=”GhostableInLibraryIgnoreIfAlreadyExists=”TRUE” />


  • Save the onet file and then deploy the project into your environment using the deploy option in “SharePoint Extensions for VS 2005”
  • When you create a new site from your site definition it should now use your new master page.

Below is a screen grab of the onet.xml file with all the changes highlighted


Categories: Uncategorized Tags: ,
  1. Ram
    12 December 2007 at 1:36 pm


    i want to add custom v3 webparts to the default.aspx page (i.e. home page) of every site definition. There are 3 configuration sections (defintions) for each of the 3 sub sites. I would like different webparts to be added to each of the default.aspx pages within the onet.xml file.

    I know that we can use the section of each configuration for that. but it does not seems to work for me.


  2. 14 December 2007 at 2:56 pm

    Have a look at the ONET.XML file for the STS template. This uses the same concept you describe above. I think the thing you will need to remember is to name the default page differently for each one. Let us know if you have anymore questions

  3. ved
    21 July 2008 at 2:37 pm

    Yes… it works for the Default.aspx page. But custom master page is not applied to “Lists/Forms/AllItems.asp” or some other inside page.

    Any solition for that??

    • 18 November 2011 at 9:49 am

      I’ll need to check, but this will have something to do with how the pages reference the master page.

      The default templates will reference default.master.

      The best thing to do is add your custom master page through a solution that deploys it and then set it as the custom master page. Have a look on CodePlex there are a number of solutions that will give you some guidance.

  4. Rishi jagati
    17 November 2011 at 9:28 am

    Can anybody explain me how to add master page in share point 2010 project folder,which is related to share point designer.

    • 18 November 2011 at 9:41 am

      Hi, I don’t understand your question. Please could you provide some more information.

      Are you trying to add a master page to a folder using SharePoint Designer?
      Are you trying to add a master page to a solution that was created in SharePoint Designer originally?

  5. s
    3 July 2012 at 12:07 pm

    hi how to create a custom site definition with applying custom master page in sharepoint 2010 any one reply to me its a great helpful for me.

  1. 16 April 2008 at 5:11 pm

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: