Provisioning a default.aspx page to use a custom page layout

sharepointsharepoint-2010

I have a custom site definition I created that deploys a couple of custom page layouts. Does anyone know what needs to be done so that when a user uses my site definition to create a site, their default.aspx page is created using my custom page layout?

Below is the module section of my site definition:

  <Modules>
    <Module Name="DefaultHome" Url="$Resources:osrvcore,List_Pages_UrlName;" Path="">
      <File Url="default.aspx" Type="GhostableInLibrary" >
        <Property Name="Title" Value="Test Home Page" />
        <Property Name="PublishingPageLayout" Value="~SiteCollection/_catalogs/masterpage/MyCustomPageLayout.aspx, My Custom PageLayout" />
        <Property Name="ContentType" Value="$Resources:cmscore,contenttype_welcomepage_name;" />
        <Property Name="PublishingPageContent" Value="Welcome to the My Test Publishing Site" />
      </File>
    </Module>
  </Modules>

Best Answer

In your onet.xml file you need to set the DefaultPageLayout property like below

<!-- Publishing Feature -->
        <Feature ID="22A9EF51-737B-4ff2-9346-694633FE4416">
          <Properties xmlns="http://schemas.microsoft.com/sharepoint/">
            <Property Key="WelcomePageUrl" Value="$Resources:osrvcore,List_Pages_UrlName;/Default.aspx" />
            <Property Key="ChromeMasterUrl" Value="~SiteCollection/_catalogs/masterpage/MyMasterPage.master"/>
            <Property Key="SimplePublishing" Value="True" />
            <Property Key="VersioningOnPages" Value="Major" />
            <Property Key="RequireCheckoutOnPages" Value="False" />
            <Property Key="AvailablePageLayouts" Value="~SiteCollection/_catalogs/masterpage/MyPageLayout.aspx:~SiteCollection/_catalogs/masterpage/MyPageLayout.aspx"/>
            <Property Key="DefaultPageLayout" Value="~SiteCollection/_catalogs/masterpage/MyPageLayout.aspx"/>
            <Property Key="AvailableWebTemplates" Value="ENTERWIKIRBKC#2;"/>                       
            <Property Key="AllowSpacesInNewPageName" Value="false"/>
          </Properties>
        </Feature>
Related Topic