2

I created a custom site template for Sharepoint 2010. In this template is automatically activated SharePoint Server Publishing feature by this code in onet.xml:

<WebFeatures>
  <Feature ID="94c94ca6-b32f-4da9-a9e3-1f3d343d7ecb" />
</WebFeatures>

I have also specified module for default page in onet.xml in this way:

(in configuration section):

<Modules>
   <Module Name="DefaultBlank" />
</Modules>

(and specified under configuration section):

<Module Name="DefaultBlank" Url=""  Path="">
  <File Url="default.aspx" Name="default.aspx" NavBarHome="True" Type="Ghostable">
  </File>
</Module>

But when I create site based on this template Sharepoint automatically redirect to NewSiteURL/Pages/default.aspx, which is something what I do not want. This default page is created automatically by publishing feature and it is blank. But I want as default page my prepared default.aspx, so address should be just NewSiteURL/default.aspx. I tried set this up by property of Publishing feature:

<Feature ID="94c94ca6-b32f-4da9-a9e3-1f3d343d7ecb">
   <Properties xmlns="http://schemas.microsoft.com/sharepoint/">
      <Property Key="WelcomePageUrl" Value="~/default.aspx"/>
   </Properties>
</Feature>

But it's not working. Does anybody know how to resolve this problem?

UPDATE:

I tried solution from Chakkaradeep but no luck with it :(. I still see blank default page when I created a site. My onet.xml now:

<?xml version="1.0" encoding="utf-8"?>
<Project Title="Custom Publishing Site" Revision="2" ListDir="" xmlns:ows="Microsoft   SharePoint" xmlns="http://schemas.microsoft.com/sharepoint/">
<NavBars>
</NavBars>
<Configurations>
  <Configuration ID="0" Name="Custom Publishing Site"   CustomMasterUrl="_catalogs/masterpage/publish.master">
  <Lists/>
  <SiteFeatures>

    <!-- Aggregation lists + instances -->
    <Feature ID="465138bd-5cbb-477c-9148-0f0846f6c323" />

    <!-- Publishing Site Infrastructure -->
    <Feature ID="f6924d36-2fa8-4f0b-b16d-06b7250180fa" />

    <!-- Custom Content Types-->
    <Feature ID="d86c7005-d31d-43ae-b86b-38f28b81072e" />

    <!-- Custom styles + images -->
    <Feature ID="cfac09fe-5aff-4b66-8c3c-22ec02af3af5" />

  </SiteFeatures>
  <WebFeatures>

    <!-- Master Page -->
    <Feature ID="4dae3485-c2e5-4c07-adcc-28a7417b6dd9" />

    <!-- Page layouts --><!--
    <Feature ID="985b3cfc-728c-4459-90d9-5d02de88857a" />-->

    <!-- Publishing Feature -->
    <Feature ID="94c94ca6-b32f-4da9-a9e3-1f3d343d7ecb">
      <Properties xmlns="http://schemas.microsoft.com/sharepoint/">
        <Property Key="WelcomePageUrl" Value="$Resources:osrvcore,List_Pages_UrlName;/Default.aspx" />
        <Property Key="SimplePublishing" Value="true" />
      </Properties>
    </Feature>

    <!--Lists definitions + instances-->
    <Feature ID="be3732cc-6f55-41c1-b62c-a24a43540fad" />


     <!--Default Page Setting--> 
    <Feature ID="538e4d0c-d335-4ce1-a2d9-bfc94f78e6c8" />

  </WebFeatures>

</Configuration>
</Configurations>
</Project>

As you can see I deplying also custom master page + list definitions on web scope. Last feature is my custom default page. It's in module called DefaultPage and elements.xml of this module looks like this:

<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
  <Module Name="DefaultPage" Url="$Resources:cmscore,List_Pages_UrlName;">
   <File Url="default.aspx" Type="GhostableInLibrary" Path="DefaultPage\default.aspx" IgnoreIfAlreadyExists="TRUE" >
    <Property Name="Title" Value="Home" />
    <Property Name="IncludeInGlobalNavigation" Value="FALSE" />
    <Property Name="ContentType" Value="Welcome Page" />
    <Property Name="PublishingPageLayout"  Value="~SiteCollection/_catalogs/masterpage/BlankWebPartPage.aspx, Blank Web Part page" />
  </File>
 </Module>
</Elements>

In default.aspx file is just this code:

<%@ Page Inherits="Microsoft.SharePoint.Publishing.TemplateRedirectionPage,Microsoft.SharePoint.Publishing,Version=14.0.0.0,Culture=neutral,PublicKeyToken=71e9bce111e9429c" %> 
<%@ Reference VirtualPath="~TemplatePageUrl" %> 
<%@ Reference VirtualPath="~masterurl/custom.master" %>

All my changes are mostly copied from Chakkaradeep's example solution which is working fine. So I really don't know where can be a problem.

3 Answers 3

1

The sample avaialble in my blog post exactly has what you are asking for :) - http://blogs.msdn.com/b/chaks/archive/2011/09/04/teched-2011-provisioning-sharepoint-sites-using-web-templates.aspx

The sample is a sandbox web template which creates a publishing site with a default page.

2
  • Hello Chakkaradeep, I have a problem with your solution. I tried to deploy your solution and it was working fine. But I can't put it in my project. It was looking very easy and clear but I have a big problem with it :(. I updated my question, please if you have a time look where can be a probelm.
    – Michal
    Sep 23, 2011 at 11:05
  • Hi Michal, The default.aspx page uses the 'Blank Web Part Page' page layout and thus your page will always be blank unless you add web parts to it. This is what defines the page layout property: <Property Name="PublishingPageLayout" Value="~SiteCollection/_catalogs/masterpage/BlankWebPartPage.aspx, Blank Web Part page" /> Sep 24, 2011 at 23:33
0

In the File element in the DefaultBlank module add a Path attribute that points to your custom default page like shown below and put the default-custom.aspx page beside the default.aspx in the SiteTemplate folder (or your sub folder):

<File Url="default.aspx" Path="default-custom.aspx" NavBarHome="True" Type="Ghostable">
2
  • Thanks for reply Bernd, unfortunately it's not working. Solution from Chakkaradeep working very well.
    – Michal
    Sep 20, 2011 at 19:00
  • Sorry, did not read your question properly... Sep 21, 2011 at 5:15
0

I solved this problem by adding this code into WebFeatures:

<Feature ID="22A9EF51-737B-4ff2-9346-694633FE4416">
      <Properties xmlns="http://schemas.microsoft.com/sharepoint/">
        <Property Key="ChromeMasterUrl" Value=""/>
        <Property Key="WelcomePageUrl" Value="$Resources:osrvcore,List_Pages_UrlName;/default.aspx"/>
        <Property Key="PagesListUrl" Value=""/>
        <Property Key="AvailableWebTemplates" Value=""/>
        <Property Key="AvailablePageLayouts" Value=""/>
        <Property Key="SimplePublishing" Value="true" />
      </Properties>
    </Feature>

It's a "Office SharePoint Server Publishing Infrastructure".

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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