2

How to change the sub-site master page URL while creating it (sub-site) ? By default, it uses "default.master" is on its "master page gallery" list, want to change the master page url in such a way that it is pointing to its parent site-collections master page's url.

2
  • I assume you mean automatically as opposed to creating a sub-site and then editing the master page through the web UI? Commented Apr 6, 2010 at 19:17
  • your understanding is correct. Commented Apr 7, 2010 at 8:15

4 Answers 4

1

If you have created your own publishing site definition, you can also do this in your ONET.xml, as part of the properties of the OOB publishing feature. See the ChromeMasterUrl property below.

<WebFeatures>
   <Feature ID="22A9EF51-737B-4ff2-9346-694633FE4416">
     <!-- Publishing -->
       <Properties xmlns="http://schemas.microsoft.com/sharepoint/">
          <Property Key="ChromeMasterUrl" Value="~SiteCollection/_catalogs/masterpage/MYCUSTOMMASTER.master"/>
          <Property Key="WelcomePageUrl" Value="$Resources:cmscore,List_Pages_UrlName;/default.aspx"/>
          <Property Key="PagesListUrl" Value=""/>
          <Property Key="AvailableWebTemplates" Value="*-MYCUSTOMPUBLISHING#1"/>
          <Property Key="AvailablePageLayouts" Value=""/>
          <Property Key="AlternateCssUrl" Value="" />
          <Property Key="SimplePublishing" Value="true" />
      </Properties>
   </Feature>
</WebFeatures>

Note this will only apply to publishing sites

4

If you want to do it automatically, you can create a Feature that upon activation changes it through code:

// get your new SPWeb
// SPWeb newSite = ...
newSite.MasterUrl = "/_catalogs/masterpage/something.master";
newSite.Update();
1

This is a simple one; open the website in Share Point Designer. Click on the site that you want to change. Go to Format --> Master Page --> Attach Master Page. Navigate to the master page that you want to use and click OK.

1

In the browser, navigate to the root of your site collection (is probably a default.aspx page). Go to Site Actions > Site Settings > Modify All Site Settings. Under the Look and Feel column click "Master page". Set the Site Master Page to the master page you want to use. Your master page must be in the /_catalogs/masterpage directory at the root of the site collection. If you want to force all sub sites to use this master page for site pages, click the "Reset all subsites to inherit this Site Master Page setting" check box. Doing so will override any master page settings for subsites.

If it's still not working...Depending on what kind of site you're working with, there may be a master page directive in the page layout or page. Open the page layout or page in SharePoint Designer and remove the MasterPageFile declaration at the top (not the whole line, just the MasterPageFile="...").

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.