Minimal or Base Master Pages
The following is a collection of stripped down master pages for your use with SharePoint 2007 sites. The master pages that ship with SharePoint (default.master, blueband.master, etc) are full of formatting code for the respective design for the master page, so to create your own master page you have to copy a master page and strip out all of formatting code (HTML, etc) in the file. With these base master pages, I have done that step for you, plus included comments tagging the Content Placeholders so you quickly identify the Content Placeholders and handle them how you see fit.
Below are some commonly asked questions, and a few notes about the file.
Please note that the base master pages include the HTML Transitional DTD that will display your site in quirks mode. Please replace the DTD if you need a more refined presentation mode for your site. A bit more info... or a lot more info.
- What is a Master Page?
Please read this post: MOSS 2007 Design Component Relationships and Diagrams.
- Hey, can't I just create my own master page?
Sure, but it is a long process. There is a set of Content Placeholders that must be included in your master page in order for it to run in SharePoint. The point of the base master pages is to provide you with that set of Content Placeholders without all of the formatting code.
- OK I downloaded this code, now what?
Create a master page in your development SharePoint site. Paste in the base master page code (in lieu of the code that is added when the file is created) and save the file to your master page gallery. I suggest using SharePoint Designer to complete these actions. In your site, apply the master page in Site Settings. View your page. Your site should now show just the Content Placeholders.
- Gak! My site looks weird now, everything is just stacked on top of each other!
Yup, the base master page has no formatting code. Take a look at your master page file and you will just see Content Placeholders. Now it is up to you to add HTML and the like to format your site. It is like putting together a puzzle, you will need to add your formatting code and piece in the Content Placeholders where you need the various SharePoint elements.
- There are Content Placeholders I don't want in my site, what do i do?
Don't delete them! The Content Placeholders have to stay in the file for SharePoint to run. If there is a Content Placeholder you don't want to use, move the code to the hidden ASP Panel located at the bottom of the file. This is a nifty trick, the ASP Panel has the visibility set to false, so while the Content Placeholders are included in the file (and ultimately your site) everything is hidden from view. You can place as few or as many Content Placeholders in this hidden panel as you like.
- The base master page still has some stuff that looks like SharePoint, why is that happening?
If you take a look at the screen shots for each base master page or at your site after applying it, there are some items that still look like SharePoint such as navigation and the web part title bars. This is because the user controls that control these elements include CSS styles outside of the master page. In order to update the look and feel of these items, you need to override the CSS that is being used for the elements. Use my CSS reference chart to help with this process.
AND THE NUMBER ONE QUESTION I GET:
- I applied the base master page, but when I view my site, I get an error.
If all you have done is paste in my base code, make sure that the Registry tags in the top of the file still has some tildes in some key spots. Anywhere there is a reference to /_controltemplates, there should be a tilde (~) before the forward slash. Avoid losing these tildes by opening the base master page file in another application other than SharePoint Designer (such as Visual Studio or Notepad) and copying the code from there for your paste into your new master page file in SharePoint Designer. See below for a code sample.
<%@ Register TagPrefix="wssuc" TagName="Welcome" src="~/_controltemplates/Welcome.ascx" %>
If you have started moving around Content Placeholders and editing the file and you get a site error, you have probably deleted a neccessary Content Placeholder or accidentally edited something to make the Content Placeholder invalid. The best thing to do is to turn off friendly error messages for your site and view the page again. Then SharePoint will tell you exactly what it is hanging up on. See the end of this page for instructions on how to turn off friendly error messages for your site.
For each base master page, there is a link to the code, and a link to a sample screen shot of what your site will look like after applying the master page code.
MOSS Collaboration Site Base Master Page AND WSS Base Master Page
There is no difference between master pages for a collaboration MOSS site and a WSS site.
MOSS Publishing Site Base Master Page
Turn off Friendly Errors
While in development, the friendly error page that SharePoint displays when your page has an error can make debugging your master page issues very difficult. You can make an easy change to your Web config file for the site to turn friendly error messages off, therefore providing you with more useful information if your page breaks. Only do the following in a development environment, you would never want to turn off friendly error messages in a production environment. Also be sure to make a back up of the file prior to editing.
- On the Web server, navigate to the site directory:
Local Drive:\Inetpub\wwwroot\wss\VirtualDirectories\[directory for site] (for example 84)
- Open Web.config in Notepad.
- Search for "CallStack". Change the CallStack status to "true".
<SafeMode MaxControls="200" CallStack="true" DirectFileDependencies="10" TotalFileDependencies="50" AllowPageLevelTrace="false">
- Search for "CustomErrors". Change the mode to "off".
<customErrors mode="Off" />
- Save and close the file.
Now when your site encounters an error, you will receive a .NET screen outlining the issue instead of the friendly SharePoint error screen. This is particularly useful with dealing with missing Content Placeholders and editing Master Pages. To turn friendly error messages back on, just walk through these steps setting the CallStack to false and CustomErrors mode to On.