August 6, 2012

Two Master Pages: Site vs. System

If you've ever messed around with master page settings via the SharePoint UI or SharePoint Designer, you may have noticed that there can be two separate master pages active for a single site. Naturally, to keep you on your toes, Microsoft decided to give them completely different names in SPD versus the UI. So what's what?!

The first and most important master page is the System master page. It is referred to as such on the UI, but is called the "Default" master page in SharePoint Designer. This master page is used by all non-publishing pages on a site (which, of course, is literally everything if you don't have Publishing features turned on). Regardless of the actual name of the .master file in the Master Page Gallery, you can reference this master page in an ASP.NET page by using "~masterurl/default.master" as the MasterPageFile attribute value in the Page directive.

The second master page, used only by publishing pages, is the Site master page. This is identified as the "Custom" master page by SharePoint Designer. It can be referenced using a shortcut value of "~masterurl/custom.master" in the Page directive.

Here's a handy chart!

UI NameSPD NameUsed ByShortcut ValueSPWeb Property
System Master PageDefault Master PageAll pages except Publishing pages~masterurl/default.master.MasterUrl
Site Master PageCustom Master PagePublishing Pages (inherit from PublishingLayoutPage class)~masterurl/custom.master.CustomMasterUrl

No comments:

Post a Comment