Sharepoint: How to change the default page layout for newly created subsites

sharepointsharepoint-2010

I'm working on a sharepoint 2010 publishing site that has many subsites. I've set up a custom master page, and several custom page layouts.

I've discovered how to set the default page layout used for newly created pages in a subsite (found at /_Layouts/AreaTemplateSettings.aspx), but I can't seem to figure out how to specify the default page layout used to create ~/Pages/default.aspx when I create a new subsite.

Right now it selects WelcomeLinks.aspx, and that's not what I want.

Is this only available if I deploy custom master pages / layouts via code, and if so, does anyone have any good examples?

Thanks.

Best Answer

The Page Layout of a newly created subsite is determined by the site definition. For example, if you create a subsite using the Publishing Site with Workflow template, then that site is created using Configuration ID="2" from 14\TEMPLATE\SiteTemplates\BLANKINTERNET\XML\onet.xml. Within that configuration is a module section that points to SubWebWelcome:

<Module Name="SubWebWelcome" Url="$Resources:osrvcore,List_Pages_UrlName;" Path="">
    <File Url="default.aspx" Type="GhostableInLibrary" Level="Draft" >
        <Property Name="Title" Value="$Resources:cmscore,IPPT_HomeWelcomePage_Title;" />
        <Property Name="PublishingPageLayout" Value="~SiteCollection/_catalogs/masterpage/WelcomeLinks.aspx, $Resources:cmscore,PageLayout_WelcomeLinks_Title;" />
        <Property Name="ContentType" Value="$Resources:cmscore,contenttype_welcomepage_name;" />
    </File>
</Module>

As you can see, SubWebWelcome provisions the default.aspx using the WelcomeLinks Page Layout.

If you want a different Page Layout for the default page, you have two options:

  1. Create a custom site definition based on BLANKINTERNET that uses your desired Page Layout.
  2. Continue to use the out of the box site definition with custom code (launched by either feature stapling or event receivers) that changes the Page Layout from WelcomeLinks.