Designing and deploying a new master page for Sharepoint Foundation 2010

January 21st, 2011 | Posted by Jeffrey Paarhuis in Developing | Good to know

This post explains how to create a new master page with a custom stylesheet and some custom images. We do this with the following steps:

  • Install  master page picker
  • Create a new master page
  • Create a stylesheet
  • Create an images folder
  • Prepare master page
  • Edit master page
  • Deploy master page

Install master page picker
First we need a feature that is going to deploy our new master page to the sitecollections. Because the Foundation version doesn’t have a master page selector, I used this fantastic very-easy-to-install feature:

It also enables us to change the master page from within the sitecollection properties.

Create new master page
The next thing to do is to copy the existing master page.

From within Sharepoint Designer you can go to the Master Pages section and copy the v4.master in the same folder and rename it to whatever you want. I generally choose the clients name.

Tip! In the folder you also find a default.master and a minimal.master file. The default.master is the old 2007 master page. The minimal.master is a master page with only the base controls, no layout whatsoever. I always use a copy of the v4 master page and not the minimalistic one, because it’s more efficient to tweak the existing master page instead of creating a new one based on the minimal.master.

Create stylesheet
We also want to apply our own custom stylesheet to the masterpage so let’s create a stylesheet.

Go to the folder Common FilesMicrosoft SharedWeb Server Extensions14TEMPLATELAYOUTS1033STYLESThemable and create an empty mystyle.css file.

Create an images folder
Now create a new folder inside the Common FilesMicrosoft SharedWeb Server Extensions14TEMPLATEIMAGES named myimages.

Tip! We create a new folder to keep our images separated so they won´t be mixed up with the ones that come with Sharepoint. Another reason is that future editing would be easier because our images are easier to find, naturally.

Prepare master page
We are going to prepare our master page to use our custom stylesheet.

Go to Sharepoint Designer and open the edit view for the mymaster.master and click the code view. Now insert the line

<sharepoint:CSSRegistration Name="/_layouts/1033/Styles/Themable/mystyle.css" After="corev4.css" runat="server"/>

just before the </head> tag. Then save the file and accept the warning for the customized page. The After=”corev4.css” ensures that the style elements in our custom stylesheet override the default css.

Edit master page
In this example I’m going to change the color of the selected ribbon header from it’s dark grey to a solid blue color. Now browse to the sharepoint page and check the html source to find out which class is being used by the selected ribbon header. In my example the class for the header of the selected ribbon is .ms-cui-tts > .ms-cui-tt-s > .ms-cui-tt-a > .ms-cui-tt-span (do you wanna know how to find these style classes easily? Check the next tip). Now we go to our mystyle.css and create this class here and give it our blue color style.

.ms-cui-tts > .ms-cui-tt-s > .ms-cui-tt-a > .ms-cui-tt-span {
    color: #0069b0;

Save the CSS file.

Tip! I highly recommend the usage of developer tools for your browser. I always use Google Chrome with the built-in developer tools. They are very accurate and easy to use. In Chrome, rightclick the item you wish to know the style from and click Inspect element. At the right side of the window you find matched CSS Rules. You can copy a CSS rule and paste it in your mystyle.css and tweak it the way you want it.

Deploy master page
Now we wan’t to test our new master page. Before we can do that we need to select it with the master page picker we installed in the first step.

Go to your sitecollection  settings and go to the Master Page Picker which can be found under the Look and Feel category. Our new master page will be displayed in the list, select it and click ok to apply our new master page to the sitecollection.

Now go to the site and check our result. The selected ribbon header text color is now blue, thumbs up!

When you use images in your stylesheet or master page then put the image in the myimages folder and reference it with the following url


Get classnames for hover items
Tip! It may be difficult to find the hover style of some elements. In Google Chrome you can do this by rightclicking the item and leave your cursor where it is and browse the menu with up and down keys on the keyboard, then select Inspect element and press enter. At the rightside of the window you now find the classnames for the hover of the item.


Some readers ran into  an error when using their new master page. The error reads The expression prefix ‘SPUrl’ was not recognized. Please correct the prefix or register the prefix in the section of configuration. This is because SharePoint Foundation doesn’t support the SPUrl prefix out of the box.

There problem is with this line of code in the master page:
Name="<% $SPUrl:~sitecollection/_layouts/1033/Styles/Themable/mystyle.css %>"
After="corev4.css" runat="server"/>

A simple solution is to just simplify the code to this
After="corev4.css" runat="server"/>

A more time-consuming but maybe better way is this:


If you want your master page to automatically get applied with every new site you create, please read this post:

You can follow any responses to this entry through the RSS 2.0 You can leave a response, or trackback.

22 Responses

  • Nice post, the only problem with this approach is that you need access to the file system which is not always possible.


    • jeffreypaarhuis says:

      Entirely true, but I guess in that case, you can put the images and stylesheets in a document library on the root site and refer to that from the masterpage.

  • mattmoo2 says:

    Nice post although sometimes you don’t have access to the file system so this wouldn’t be the best method in that scenario.


  • Steve says:

    Hi, I follow this bit by bit but i end up with the following error when loading the page:

    The expression prefix ‘SPUrl’ was not recognized. Please correct the prefix or register the prefix in the section of configuration.

    Troubleshoot issues with Microsoft SharePoint Foundation.

    Correlation ID: 6470c9d6-7371-4435-9b92-ed69719dc348

    Date and Time: 6/23/2011 6:13:09 PM

    Any Help would be greatly appreciated!


  • Steve says:

    Hey, thanks for the reply. I get this error when trying to load the webpage back up in internet explorer.

    Many Thanks,

  • Emmi says:

    I tried doing this as well and I got the exact same error as Steve did. I got it when I had added and deployed the solution and once I had clicked OK when taking the new master page into use via the Master Page Picker. The problem is not only that the front page of the service won’t open. The problem is that the only page that doesn’t render the same error message is the Site Settings page. For instance even the Master Page Picker now gives the same error message so I can’t even switch back to the old v4.master.


    • jeffreypaarhuis says:

      Ok there seems to be a problem with this line of code in the masterpage:
      Name="<% $SPUrl:~sitecollection/_layouts/1033/Styles/Themable/mystyle.css %>"
      After="corev4.css" runat="server"/>

      A simple solution is to just simplify the code to this
      After="corev4.css" runat="server"/>

      A more time-consuming but maybe better way is this:

  • Emmi says:


    thank you so much for the quick answer. That helped and now the new master page works like a charm.


  • husso says:

    Hi Jeffrey,

    I could deploy the new master page picker and put some stylings.
    I created a second site and ticked the “Apply to all sites?” to see whether the 2.nd site can now have the same look as the first site. I cannot see any difference.
    How do you apply the new master page? Once on the main site or every time go to site settings when a new site created and tick “Site collection” in “master page picker”?


  • Pingback: Your master page automatically on newly created (sub)sites « Jeffrey Paarhuis: SharePoint Blog

  • kriss says:

    Hi jeffreypaarhuis, I need some guidance or example that how to deploy a master page developed in visual studio to sharepoint.
    kind regards

    • jeffreypaarhuis says:

      Maybe you can give me some context. What are you trying to accomplish? Note that there’s a big difference between the normal and the SharePoint master page.

  • asad says:

    As you mentioned we can access images like /_layouts/images/myimages/.png. But how you will fix when you are at application pages i.e. http://[portal_url]/_layouts/_layouts/images/CustomMaster/Logo.png


    • jeffreypaarhuis says:

      I don’t exactly know what you mean, but I guess it’s how you can use an image in an application page. If thats the case then the answer is pretty simple. You can still use the same /_layouts/images/CustomMaster/image.png because that is the path where the image resides, no matter what location the page you are making is on.

  • Atiq says:

    very nice article and thanks. Would you please suggest how i can set this master page to only one site page only (webpart page i.e. test.aspx)? i dont want to apply customized master page to all sites but only one site page.
    Many thanks

    • Open the page you want it applied to in SharePoint designer, go to code view and replace MasterPageFile=”~masterurl/default.master” of the Page tag to MasterPageFile=”~site/_catalogs/masterpage/yourmasterpage.master”

      Unfortunately, this solution can only be applied to site pages and not publishing pages, you need some code for that.

      • Atiq says:

        Thank you so much Jeffrey Paarhuis. I even don’t find Microsoft paid services so caring and quick reply. I am using SharePoint Foundation 2010 which don’t have publishing feature. I have created a new webpart page and was getting exception on attaching custom master page but you solved my problem like an angle. Best Regards

Leave a Reply

%d bloggers like this: