SharePoint Config

Ari Bakker's thoughts on customising and configuring SharePoint

Minimal SharePoint Master Page

with 6 comments

Master pages provide a great platform for branding custom SharePoint sites. By default, however, the master pages included with WSS and MOSS sites include a lot of unnecessary mark-up. As I like to keep my code as clean as possible a while ago I tried using the Microsoft minimal master page. This worked fine for most of the site but I found when I used this for the system pages (think viewing document libraries, editing list items…) things started to break. In the end I opted for another one I found that wasn’t quite the bare minimum, but it worked.

Recently I went back to the Microsoft site and noticed that they had been making changes to their minimal master page based on the community feedback they had received on their article. I was impressed. Enough even to give it another shot, and although I found one missing element I was able to get it working as a master page for both my site and system pages.

The problem that I found was that the default pages for adding and editing list items were missing the PlaceHolderTitleRightMargin content placeholder. So if you add the following line to the list of content placeholders in the hidden div you should now be able to have a fully working master page with only the bare minimum required to get your site working:

The reason we need this is that the default aspx page that SharePoint serves up for editing list items contains content for the PlaceHolderTitleRightMargin placeholder. If it cannot find this placeholder in the master page then we get the error:

Cannot find ContentPlaceHolder ‘PlaceHolderTitleRightMargin’ in the master page ‘~masterurl/default.master’, verify content control’s ContentPlaceHolderID attribute in the content page.

Take a look at the MSDN article How to: Create a minimal master page for more information.

Update 6 May:

Word from Microsoft is that they do not support using their minimal.master page for system pages so I have amended their minimal.master to support these pages as well. The following will work for both site and system pages.

<%-- Identifies this page as a .master page written in C# and registers tag prefixes, namespaces, assemblies, and controls. --%>
<%@ Master language="C#" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "">
<%@ Import Namespace="Microsoft.SharePoint" %>
<%@ Register Tagprefix="SPSWC" Namespace="Microsoft.SharePoint.Portal.WebControls" Assembly="Microsoft.SharePoint.Portal, Version=, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Register Tagprefix="SharePoint" Namespace="Microsoft.SharePoint.WebControls" Assembly="Microsoft.SharePoint, Version=, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Register Tagprefix="WebPartPages" Namespace="Microsoft.SharePoint.WebPartPages" Assembly="Microsoft.SharePoint, Version=, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Register Tagprefix="PublishingWebControls" Namespace="Microsoft.SharePoint.Publishing.WebControls" Assembly="Microsoft.SharePoint.Publishing, Version=, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Register Tagprefix="PublishingNavigation" Namespace="Microsoft.SharePoint.Publishing.Navigation" Assembly="Microsoft.SharePoint.Publishing, Version=, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Register TagPrefix="wssuc" TagName="Welcome" src="~/_controltemplates/Welcome.ascx" %>
<%@ Register TagPrefix="wssuc" TagName="DesignModeConsole" src="~/_controltemplates/DesignModeConsole.ascx" %>
<%@ Register TagPrefix="PublishingVariations" TagName="VariationsLabelMenu" src="~/_controltemplates/VariationsLabelMenu.ascx" %>
<%@ Register Tagprefix="PublishingConsole" TagName="Console" src="~/_controltemplates/PublishingConsole.ascx" %>
<%@ Register TagPrefix="PublishingSiteAction" TagName="SiteActionMenu" src="~/_controltemplates/PublishingActionMenu.ascx" %>
<%-- Uses the Microsoft Office namespace and schema. --%>
<WebPartPages:SPWebPartManager runat="server"/>
<SharePoint:RobotsMetaTag runat="server"/>
<%-- The head section includes a content placeholder for the page title and links to CSS and ECMAScript (JScript, JavaScript) files that run on the server. --%>
<head runat="server">
<asp:ContentPlaceHolder runat="server" id="head">
<asp:ContentPlaceHolder id="PlaceHolderPageTitle" runat="server" />
<Sharepoint:CssLink runat="server"/>
<asp:ContentPlaceHolder id="PlaceHolderAdditionalPageHead" runat="server" />
<%-- When loading the body of the .master page, SharePoint Server 2007 also loads the SpBodyOnLoadWrapper class. This class handles .js calls for the master page. --%>
<body onload="javascript:_spBodyOnLoadWrapper();">
<%-- The SPWebPartManager manages all of the Web part controls, functionality, and events that occur on a Web page. --%>
<form runat="server" onsubmit="return _spFormOnSubmitWrapper();">
<wssuc:Welcome id="explitLogout" runat="server"/>
<PublishingSiteAction:SiteActionMenu runat="server"/>
<PublishingWebControls:AuthoringContainer id="authoringcontrols" runat="server">
<PublishingConsole:Console runat="server" />
<%-- The PlaceHolderMain content placeholder defines where to place the page content for all the content from the page layout. The page layout can overwrite any content placeholder from the master page. Example: The PlaceHolderLeftNavBar can overwrite the left navigation bar. --%>
<asp:ContentPlaceHolder id="PlaceHolderMain" runat="server" />
<asp:Panel visible="false" runat="server">
<%-- These ContentPlaceHolders ensure all default SharePoint Server pages render with this master page. The only content placeholders required are those that are overridden by your page layouts. --%>
<asp:ContentPlaceHolder id="PlaceHolderSearchArea" runat="server"/>
<asp:ContentPlaceHolder id="PlaceHolderTitleBreadcrumb" runat="server"/>
<asp:ContentPlaceHolder id="PlaceHolderPageTitleInTitleArea" runat="server"/>
<asp:ContentPlaceHolder id="PlaceHolderLeftNavBar" runat="server"/>
<asp:ContentPlaceHolder ID="PlaceHolderPageImage" runat="server"/>
<asp:ContentPlaceHolder ID="PlaceHolderBodyLeftBorder" runat="server"/>
<asp:ContentPlaceHolder ID="PlaceHolderNavSpacer" runat="server"/>
<asp:ContentPlaceHolder ID="PlaceHolderTitleLeftBorder" runat="server"/>
<asp:ContentPlaceHolder ID="PlaceHolderTitleAreaSeparator" runat="server"/>
<asp:ContentPlaceHolder ID="PlaceHolderMiniConsole" runat="server"/>
<asp:ContentPlaceHolder id="PlaceHolderCalendarNavigator" runat ="server" />
<asp:ContentPlaceHolder id="PlaceHolderLeftActions" runat ="server"/>
<asp:ContentPlaceHolder id="PlaceHolderPageDescription" runat ="server"/>
<asp:ContentPlaceHolder id="PlaceHolderBodyAreaClass" runat ="server"/>
<asp:ContentPlaceHolder id="PlaceHolderTitleAreaClass" runat ="server"/>
<asp:ContentPlaceHolder id="PlaceHolderBodyRightMargin" runat="server"/>
<asp:ContentPlaceHolder id="PlaceHolderTitleRightMargin" runat="server"/>

Post to Twitter Post to Delicious Post to Digg Post to Reddit Post to StumbleUpon

Written by Ari Bakker

April 30th, 2007 at 9:28 am

6 Responses to 'Minimal SharePoint Master Page'

Subscribe to comments with RSS or TrackBack to 'Minimal SharePoint Master Page'.

  1. I definately use Frontpage still for non-SharePoint html editing and find the SharePoint designer great for what it was really targetted to… SharePoint layouts.

    FP 2003 installs nicely next to Office 2007.

    Expression has a place and I am just now starting to get a grip on it and am liking what I see.

    I think the world still needs a great html editor and for The Foundation, we will stick with FP.

    Just Bill

    9 Nov 07 at 6:13 am

  2. I dont know how anyone can be expected to fumble about sharepoint designer 2007 and the mess that is master pages themes and code.

    A terrible aparent replacement for frontpage. Some of my clients have asked about migrating from frontpage. They dont know if they should be upgrading to expression web or sharepoint designer.

    I say <em> Forget about Microsoft Products </em>


    6 Nov 07 at 3:17 pm

  3. Thanks for this :)! It's just what I was looking for.


    30 Sep 09 at 2:27 am

  4. I must be missing something here, I can design active server site master pages in VS2005 no problem at all, but in Sharepoint no deal. Why I can't use VS to create Sharepoint masterpages is beyond me. Maybe I am wrong but it seems to me MS must have a department that does nothing but come up with ways to "piss off" developers.


    7 Jul 09 at 11:16 am

  5. when I attempt via SharePoint Designer to open a simple page (originally created via a browser in our sharepoint site). This page was created using the default BlankWebPartPage.aspx

    The SP Designer asks me if I want to check out this default BlankWebPartPage.aspx? Why? I do not want to mess with this default files.
    Just the file that inherits it that I created!!!! any ideas?

    If I say yes open BlankWebPartPage.aspx; then it says "server access denied" error but goes ahead and opens this template BlankWebPartPage.aspx????

    BUT does not open the file I asked it to open.

    Adrian Curley

    25 Feb 09 at 10:44 pm

  6. This didnt work for me at all. It returns a master page error


    12 Nov 08 at 11:02 pm

Leave a Reply