Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

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?

share|improve this question

4 Answers 4

up vote 5 down vote accepted

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.

share|improve this answer
    
Remember to add List="116" like I've shown below. –  tarjeieo May 20 '11 at 7:57
    
Thanks, tarjeieo. I just updated the code. –  Laurie May 20 '11 at 8:24
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 '11 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 '13 at 0:42

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>
share|improve this answer
    
Hi! Welcome to SP.SE! You know you did answer a 2 years old post? :) –  Robert Lindgren Nov 24 '13 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 '13 at 9:32
    
Absolutely :) It was merely a comment on your salution, that was a bit out there ;) –  Robert Lindgren Nov 24 '13 at 10:06

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.

share|improve this answer
    
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 '11 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 '11 at 6:47

The master page can't 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 where it can't be activated and used.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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