SharePoint Applied: What you should know about The MasterPage in SharePoint 2010

MasterPages were first introduced in SharePoint 2007. Just like in ASP.NET, they allow you to define a base layout, minimum criterion and even some basic logic for all pages that choose to use that master page.

The recommendation in SharePoint is to not create pages that do not use a master page. In other words, barring very simple tasks like download.aspx, don’t go around creating ASPX’s that are pure ASP.NET pages with no bearing to SharePoint pages.

The good news, however, is that you do have the capability to create your own master pages in SharePoint 2010 and SharePoint 2007. The even better news is that creating master pages in SharePoint 2010 is a lot cleaner and easier than crafting up SharePoint 2007 master pages.

Branding SharePoint - the 30,000 Foot Overview

Branding SharePoint involves making your SharePoint site your own - making it look like your own, giving it your own colors, your own images, and your own styles. By far, crafting up MasterPages is not the only way of branding SharePoint. You have the ability to use different site definitions to give SharePoint a certain look and feel and feature set. You can edit the CSS or specify alternate CSS. You can use some out-of-the-box master pages, or you can even create your own themes in PowerPoint. In addition, you have the ability to use wikis for very easy content editing and format changes at a page level and you can use many of the preset Web Part pages templates to create pages in a certain specified structure. There are also numerous out-of-the-box Web Parts that let you do some serious branding with XSLT.

For this article, however, I will focus on the master page story only.

SharePoint 2010 is sold in two main categories - free and not free. The not free version is sold in many permutations and combinations. It is important to realize that the not free version of SharePoint is built using the free version of SharePoint, so any master page that is built for SharePoint foundation (the free version), will also work in SharePoint server (the not free version). The converse may not be true, however - of specific mention is the publishing template, available in SharePoint server, intended to be used for WCM scenarios. The publishing template, allows users to author rich and structured content as web pages using SharePoint and is intended for Internet facing scenarios - though many choose to use it for intranets and extranets as well. Since the WCM site is intended for Internet facing sites, it comes with many branding and content authoring facilities - including its own family of master pages. With this background, let’s examine the major categories of master pages available in SharePoint 2010.

V4.Master

This is the staple master page in SharePoint 2010. When you create a SharePoint site based on the default site definition, you are using the v4.master page. This master page is also available in SharePoint foundation. You can see the default look of SharePoint in v4.master in Figure 1.

SharePoint Applied: What you should know about The MasterPage  in SharePoint 2010

Figure 1: The v4.master page.

This page is quite similar to what used to be the staple master page in SharePoint 2007 - the default.master page, but the biggest notable addition here is the addition of the ribbon. The ribbon is this area full of buttons that appears at the top of any page; the cool thing is that those buttons can change depending upon what context you are working in. Not only that, the ribbon is cleverly styled to always stay on top of the page, you should not break this rule. You can see the v4.master’s ribbon in Figure 2, along with how it behaves with scrollbars.

SharePoint Applied: What you should know about The MasterPage  in SharePoint 2010

Figure 2: The ribbon is placed above the scrollbar.

Minimal.master

Master pages are great. They give you so much for free. Any aspx that wishes to use the ribbon and the styling of your site simply uses that master page - how convenient. But sometimes all this help a master page gives you appears like the four scouts that helped an old lady cross the road - Why did it take four scouts? Because the lady was unwilling to cross the road.

The minimal master page has been given to you to solve that need - it gives you some basic navigation controls, but plenty of open space. The idea is that you take control of almost all the page. A good example of such a page would be the start page of the search center (Figure 3). It goes without saying that you shouldn’t overuse this master page as it lacks a lot of basic SharePoint controls. Also, there are standard concepts and styles built into SharePoint such as the s4-nodlg style, if you wish to have ribbon-less pages working in modal dialog boxes.

SharePoint Applied: What you should know about The MasterPage  in SharePoint 2010

Figure 3: The minimal.master in use on the search center.

NightAndDay.master

Now this is a really interesting master page that you will use almost very frequently and invariably temporarily. Temporarily because you will most definitely end up customizing it to suit your Internet facing site needs. When you create a new SharePoint site based on the publishing template, you would see a page as shown in Figure 4.

SharePoint Applied: What you should know about The MasterPage  in SharePoint 2010

Figure 4: The nightandday.master with some strange looking people on the home page.

Ever wondered who those people are on this site? Me too! And I have no idea who they are. But what I can tell you is that the publishing site definition is using an out-of-the-box nightandday.master page that is a very clean and well thought out master page for Internet facing sites. If you are working on a serious SharePoint branding project, you probably want to start with this master page. You may notice, however, that the ribbon is nowhere to be seen in this master page. Well, that is one of the peculiar things about the publishing template - the ribbon is hidden by default, though logged in users can choose to see it. And it is hidden completely for anonymous users.

Simple.master

This is a super simple (as the name suggests) master page that is used where you want bare minimum SharePoint functionality. Examples of such pages are unauthenticated pages such as login.aspx, or error.aspx. Note that there is a simple.master, and a simplev4.master designed specifically for SharePoint 2010. Simplev4.master is used in SharePoint by the following pages:

  • Login.aspx
  • SignOut.aspx
  • Error.aspx
  • ReqAcc.aspx
  • Confirmation.aspx
  • WebDeleted.aspx
  • AccessDenied.aspx

default.master

SharePoint 2010 is immensely better than SharePoint 2007. One day I will probably say that SharePoint 2013 (I have no idea what date it will be) is immensely better than SharePoint 2010 too. The reality is that every subsequent version will be better, but business users are stubborn and reticent to change. While you on the IT side may want to take advantage of the new versions, your end users may not be ready, yet! In order to support that short transition time, Microsoft has provided you with a standard out-of-the-box default.master master page that can be applied to any SharePoint site. By doing so, your SharePoint 2010 site starts to look and behave like a SharePoint 2007 site. While this is very cool, you must use this as a transitionary/temporary phase only. You can be assured that there will be functionality in the ribbon that will not be created elsewhere. For instance, the new content editor Web Part exposes a lot of editing functionality only through the ribbon.

Summary

There used to be a joke about SharePoint 2003 - that you can always tell a SharePoint 2003 site, but you can’t tell it much. In other words, branding a SharePoint 2003 site was like you trying to sleep at 2AM because you were worried about an early morning meeting, while a four-year old girl is sticking chewing gum in your hair and her brother is playing a drum. It wasn’t easy! With SharePoint 2007 the story became a whole lot easier - but not easy enough. SharePoint 2007 master pages were complex, and there were many differences and finer points to consider when you started with working with a particular master page, suited for a particular situation. SharePoint 2010 makes the story a whole lot cleaner and better - there is much lesser parity between master pages, the pages are cleaner, and the generated HTML is also much cleaner. Now clearly, that isn’t the whole story - a SharePoint master page is usually far more complex than your regular typical ASP.NET master page. More on that in future articles.