An installation of SharePoint 2010 contains many master pages. There are master pages that preserve backward compatibility for sites migrated from WSS 3.0 or MOSS 2007 including the old master page for Team sites, default.master, and master pages for application pages including simple.master and application.master.
There are also new master pages that support the new look and feel of SharePoint 2010. These are the v4 master pages and generally speaking, there is a v4 master page that corresponds to the old master pages. For example, v4.master is the replacement for default.master and simplev4.master is the replacement for simple.master.
Master Page Locations
You can find SharePoint’s various master pages in a few different locations depending on the master page and the context of its use. Within a SharePoint site, master pages are in a document library called the Master Page Gallery. The URL for this library relative to the Web’s URL is _catalogs/masterpage.
When you create a site, SharePoint provisions the appropriate master pages from the SharePoint root to the Master Page Gallery. The stock master pages that deploy to the Master Page Gallery from the SharePoint root are in Template\Global. However, there are additional master pages that support various application and administration pages that never deploy to a site located in Template\Layouts and in Template\Admin.
Often you can find additional custom master pages in the SharePoint root as part of features that deploy master pages via a Module feature element or as part of a custom site template.
Associating Master Pages with Content Pages
You can associate a master page with a content page in several ways. Some of these are dynamic and resolve at runtime to the SPWeb’s MasterUrl or CustomMasterUrl property, while others are static.
To create a dynamic association, use one of the following tokens as the value of the MasterPageFile attribute in the Page directive.
Figure below shows the ~masterurl/default.master token in action in SharePoint
Designer. In this case it resolves to /_catalogs/masterpage/v4.master, but you
could change the SPWeb.MasterUrl property; the master page would change
without modifying the content pages.
Alternatively, you can specify the exact master page you want your content page to use with one of the static tokens.
The page parsers interpret both sets of tokens at runtime, but it is also possible to control the selection of a master page dynamically with .NET code in a page’s OnPreInit method or by using an HttpModule.
This post is an excerpt from the online courseware for our Microsoft SharePoint 2010 for Developers course written by expert Doug Ware.
Doug Ware is a SharePoint expert and an instructor for many of our SharePoint 2007 and SharePoint 2010 courses. A Microsoft MVP several times over, Doug is the leader of the Atlanta .NET User Group, one of the largest user groups in the Southeast U.S., and is a frequent speaker at code camps and other events. In addition to teaching and writing about SharePoint, Doug stays active as a consultant and has helped numerous organizations implement and customize SharePoint.