8

I've created a root site collection from the Publishing site collection template and am using a custom master page to style the site.

If I create another site collection how am I able to use the same master page?

Will it make any difference if the new site collection is a publishing site as well?

4 Answers 4

6

If you want to copy your master page to another site collection you can download your master page from the master page gallery and upload it to the the master page gallery of the second site collection. From the root site Site Actions > Site Settings > (Galleries)Master pages and page layouts

If you want to deploy the same master page to multiple site collections using a feature, create a module in Visual Studio, add your custom master page to the module, and create an element manifest something like this:

<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
  <Module Name="Master Pages" List="116" Url="_catalogs/masterpage" RootWebOnly="TRUE">
    <File Path="Master Pages\MyCustom.master" Url="MyCustom.master" Type="GhostableInLibrary"></File>
  </Module>
</Elements>

The basic idea is to have your site-scoped feature include a module that copies your custom master page from the file system to the masterpage gallery. Since the feature folder is shared, the same master page gets copied to the site collection master page gallery whenever you activate the feature.

3
  • Remember to add List="116" like I've shown below.
    – tarjeieo
    May 20, 2011 at 7:57
  • 1
    I second the approach of using a feature to push the master page to the site collection. You can also apply the necessary event receivers in your feature to automatically set the appropriate master on activation so that the feature pushes mycustom.master to the gallery then sets the site collection master to mycustom.master. Note that in 2010 you'll need to use a custom version of minimal.master on search centers. The search center will break if you set it to a master based off of v4.master. Your event receiver can automate this.
    – webdes03
    May 20, 2011 at 12:56
  • Don't you need to copy all the site assets over too? I see I needed to copy the style sheet which you didn't mention either.
    – user16948
    May 13, 2013 at 0:42
3

The master page can be copied in designer and pasted into the new site collection. A better approach would be to bundle it into a feature and deploy it to the farm.

1

The below is straight from MSDN: http://msdn.microsoft.com/en-us/library/vstudio/ee231567(v=vs.100).aspx

To sum up for your convenience:

Module Name is the name of the module file in your VS project which defaults to Module1. So if you have renamed it, then make sure Module Name is renamed in the elements file too.

Also note backslash "\" for Path, and forward slash "/" for Url.

Also the Url in Module Name refers to where in SP you want to place the file.

And the Path in File refers to where the file is in your project.

So, here it is:

<?xml version="1.0" encoding="utf-8"?>

<Elements xmlns="http://schemas.microsoft.com/sharepoint/">

  <Module Name="Module1" Url="_catalogs/masterpage" RootWebOnly="TRUE">

    <File Path="Module1\Sample.txt" Url="Module1/Sample.txt" />

  </Module>

</Elements>
3
  • Hi! Welcome to SP.SE! You know you did answer a 2 years old post? :) Nov 24, 2013 at 7:41
  • 1
    Yes, and SP2010 is alive and well, being the most deployed version of SharePoint in the marketplace today. So this thread will remain relevant for a very long time to come.
    – SonicVader
    Nov 24, 2013 at 9:32
  • Absolutely :) It was merely a comment on your salution, that was a bit out there ;) Nov 24, 2013 at 10:06
0

In your master page module Elements.xml, remember to add List="116", like the following snippet shows, or you will get error e.g. when activating the Publishing feature.

<Module Name="MasterPages" List="116" Url="_catalogs/masterpage"> 
  <File Path="MasterPages\custom_main.master" Url="custom_main.master" Type="GhostableInLibrary" /> 
</Module>

In order for the changes to be correctly applied, delete the masterpage from the master page gallery, and deploy the solution again.

2
  • Is this a 2007 vs. 2010 thing? I can honestly say I've never added List="116" to any of my 2010 branding features and I've never seen the error you describe. I'm thinking Path and List can be used interchangeably, but one must be there. Sorry for the poor formatting in a comment, here's an example of what I usually use: <Module Name="MasterPageGallery" Path="MasterPageGallery" Url="_catalogs/masterpage"><File Url="custom.master" Type="GhostableInLibrary"><Property Name="UIVersion" Value="4"/><Property Name="ContentTypeId" Value="0x010105"/></File></Module>
    – webdes03
    May 20, 2011 at 13:14
  • Well, I had a problem with this at least, and adding List=116 fixed the issue: sharepoint.stackexchange.com/questions/12056/…
    – tarjeieo
    May 23, 2011 at 6:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.