Skip to content

Custom Master Pages and Site Definitions in WSSv3 (and MOSS2007)

Master pages are a very powerful new feature in WSSv3 (and MOSS2007 by extension).  They allow you a level of control that just wasn’t possible in WSSv2.  However, with anything new there can be some misunderstandings.  I wanted to share a few things that I’ve discovered while trying to get my custom master pages working.

First, we’re creating a new site definition here so let’s start with that.  Todd Baginski’s post “HOW TO: Creating a custom Site Definition in MOSS 2007” is a good walkthrough.  Next we need a custom master page.  A copy of the default.master from …12\TEMPLATE\GLOBAL makes a good starting point.  Drop that off in your new site definition directory.

Now it’s time for some modifications, first, you may want to rename your default.master you copied into your site definition.  You can use custom.master if you want – or any other name, it doesn’t matter.  Next, open your default.aspx file and change the MasterPageFile attribute on the top line to read “~masterurl/custom.master” – use this string even if your custom master page isn’t named custom.master.  SharePoint does a string replacement of this string with the value contained in the CustomMasterUrl property of the site (SPWeb).  Save the default.aspx file and repeat the process for defaultdws.aspx.  (If you want to know more about the string replacement you can look at the “Customizing Master Pages in Windows SharePoint Services” SDK entry.)

Now we need to connect that to your site definition.  That’s in your ONET.XML in the XML subdirectory of the site definition.  Locate the Configuration node.  Add a CustomMasterUrl attribute and set it to “_catalogs/masterpage/mypage.master” where mypage.master is the actual name that you gave your new master page.  Now in the Modules nodein the configuration add a new Module tag referencing a new module definition you’ll define in a second.  The node should look something like:

<Module Name=”CustomMasterPage” />

Help Your SharePoint User

After the <Configurations> node/section there’s a module node section.  In this section add:

<Module Name=”CustomMasterPage” List=”116″ Url=”_catalogs/masterpage” RootWebOnly=”FALSE”>
<File Url=”mypage.master” Type=”GhostableInLibrary” IgnoreIfAlreadyExists=”TRUE” />

Again, replace mypage.master with whatever you named your custom master page.

At this point you’re done.  You can save the files, do an IIS reset and use your site with a custom master page.

A few notes about the whole process:

1)      The “Customizing Master Pages in Windows SharePoint Services” SDK entry seems to indicate that you need to set both MasterUrl and CustomMasterUrl whenever you customize the master page – this isn’t correct.  You can simply modify the CustomMasterUrl if you wish.  This is a preferred approach for me because then you can change your default.aspx back to use a MasterPage of ~masterurl/default.master if you encounter issues with your custom master page.  Of course, if you do this your pages will need to reference ~masterurl/custom.master to get your custom master page.

2)      In the comments of Todd’s post “HOW TO: Creating a custom Site Definition in MOSS 2007”, Dan gives most of the information here – with a few extras.  One of the extra things that he includes is a <ListTemplate>.  If you include this node the site will work fine when created directly from a site definition, but it won’t work if you recreate the site from a site template.  For some reason, SharePoint ignores this node on creation from a site definition – but not when being recreated from a site template.  You’ll get some errors provisioning the global masterpage gallery in the ULS logs and a SharePoint File Not Found error.  However, the snipit works fine without the ListTemplate node.

Special thanks to Quang Sun who drew the PSS case I opened to get this all straightened out.


  1. Hello.
    I’m new there
    Nice forum!

  2. Hey… sorry for my english, where I can [b]download XRumer 5.0 Palladium FOR FREE[/b]??? Thanks!!!
    It’s perfect software for promo and SEO, but cant find any crack for it((
    cracked XRumer 2.9 and XRumer 3.0 are too old, Im need FRESH!

  3. Never underestimate the power of the internet. An increasing number of people use the internet
    to search for a business or service so having a web presence is an important media for promoting
    your company. Web design is a real skill and if your website is to not only look good but work well,
    it should be constructed by a professional web designer.

    If you are interested, you can contact me: hqwebdesign (AT) gmail (DOT) com

  4. Hello eveyone, I’m new to the forum
    I look forward to sharing and exchanging information with everyone!
    I have been watching the forum for a while and I just decided to join and participate!
    See ya…

  5. Your welcome everyone,
    My computer worked slowly, many mistakes and buggs. Help me, please to fix buggs on my PC.
    My operation system is Windows XP.

  6. The member community, Legit Online Job, offers the attractive suggestions to earn money just being at home. This way of making money is increasingly in demand and wanted all over the Internet. And that’s why it is not surprising that a lot of buncos make their benefits as well. Legit Online intends to find way around and offer you a profitable deal within online. Legit Online Jobs provides the very jobs which are well proven. It is also a great chance to manage your own online business through dozens of available advertisements and meanwhile never be afraid to be

  7. just read the thread. great job.

  8. Just now looked through the topic. Amazing work.

Add a Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Share this: