Question

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.

Was it helpful?

Solution

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

OTHER TIPS

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();

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.

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="...").

Licensed under: CC-BY-SA with attribution
Not affiliated with sharepoint.stackexchange
scroll top