# Provisioning a Welcome Page to Pages Library

I have a custom Web Template which enables the default features of a Publishing Site and in addition it enables custom Features e.g. WelcomePageProvisioning. It's kinda straight forward, but still I get an error: "A list, survey, discussion board, or document library with the specified title already exists in this Web site. Please choose another title."

Web Template Elements.xml:

<WebTemplate
Name="WTStackExchangePublishing"
BaseTemplateName="CMSPUBLISHING"
BaseTemplateID="39"
BaseConfigurationID="0"
Title="StackExchange Publishing site"
Description="StackExchange Publishing site template"
DisplayCategory="StackExchange" />


StackExchange Web Template onet.xml:

<Project Revision="3" Title="$Resources:cmscore,IPPT_Project_Title;" ListDir="Lists" xmlns:ows="Microsoft SharePoint" UIVersion="4"> <NavBars> <NavBar Name="SharePoint Top Navbar" ID="1002"></NavBar> </NavBars> <ListTemplates> </ListTemplates> <Configurations> <Configuration ID="0" Name="BLANKINTERNET"> <SiteFeatures> <!-- Activating SharePoint Server Publishing Infrastructure--> <Feature ID="F6924D36-2FA8-4f0b-B16D-06B7250180FA"></Feature> </SiteFeatures> <WebFeatures> <!-- Include the common WSSListTemplateFeatures used by CMS --> <Feature ID="00BFEA71-DE22-43B2-A848-C05709900100" > </Feature> <Feature ID="00BFEA71-E717-4E80-AA17-D0C71B360101" > </Feature> <Feature ID="00BFEA71-52D4-45B3-B544-B1C71B620109" > </Feature> <Feature ID="00BFEA71-A83E-497E-9BA0-7A5C597D0107" > </Feature> <Feature ID="00BFEA71-4EA5-48D4-A4AD-305CF7030140" > </Feature> <Feature ID="00BFEA71-F600-43F6-A895-40C0DE7B0117" > </Feature> <Feature ID="22A9EF51-737B-4ff2-9346-694633FE4416"> <!-- Publishing --> <Properties xmlns="http://schemas.microsoft.com/sharepoint/"> <Property Key="WelcomePageUrl" Value="$Resources:osrvcore,List_Pages_UrlName;/default.aspx"/>
<Property Key="PagesListUrl" Value=""/>
<Property Key="AvailableWebTemplates" Value="*-{e7416bda-dbf1-4e53-bb1c-2215f645abc5}#WTStackExchangePublishing;"/>
<Property Key="AvailablePageLayouts" Value="~SiteCollection/_catalogs/masterpage/BlankWebPartPage.aspx"/>
<Property Key="DefaultPageLayout" Value="~SiteCollection/_catalogs/masterpage/BlankWebPartPage.aspx" />
<Property Key="AlternateCssUrl" Value="" />
<Property Key="SimplePublishing" Value="false" />
</Properties>
</Feature>
<Feature ID="541F5F57-C847-4e16-B59A-B31E90E6F9EA">
<!-- Per-Web Portal Navigation Properties-->
<Properties xmlns="http://schemas.microsoft.com/sharepoint/">
<Property Key="InheritGlobalNavigation" Value="true"/>
<Property Key="IncludeSubSites" Value="true"/>
<Property Key="IncludePages" Value="true"/>
</Properties>
</Feature>
<!-- Office SharePoint Server Publishing -->
<Feature ID="94C94CA6-B32F-4da9-A9E3-1F3D343D7ECB"></Feature>

<!-- StackExchange Welcome Page Provisioning -->
<Feature ID="5c3e91cd-1157-4101-a108-1d1e4318f02e" />
</WebFeatures>
</Configuration>
</Configurations>
</Project>


StackExchange Welcome Page Elements.xml

<Module Name="DefaultHome" Url="\$Resources:osrvcore,List_Pages_UrlName;">
<File Url="default.aspx" Type="GhostableInLibrary" Level="Draft" Path="WPStackExchangePublishing\default.aspx">
<Property Name="Title" Value="Welcome" />
<Property Name="PublishingPageLayout" Value="~SiteCollection/_catalogs/masterpage/BlankWebPartPage.aspx, Blank Web Part Page" />
<Property Name="ContentType" Value="Welcome Page" />
</File>
</Module>


StackExchange Welcome Page default.aspx

<%@ 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" %>


I'm stuck at the moment. A thing to mention is that I'm using a sandbox solution. Any suggestions on how I would be able to get this working? Any help is greatly appreciated!

-

## 2 Answers

Oh that is simple, there is a trick though, see example below (the secret lies in the SetupPath attribute) and then make sure you link it to the actual Associated Content Type

    <Module Name="Per-Web Pages" Url="Pages" SetupPath="SiteTemplates\SPS" RootWebOnly="FALSE">
<File Url="browse.aspx" Path="default.aspx" Type="GhostableInLibrary">
<Property Name="Title" Value="Browse all Articles"/>
<Property Name="PublishingPageLayout" Value="~SiteCollection/_catalogs/masterpage/KC-BlankWelcome.aspx, Blank Welcome Page"/>
<Property Name="ContentType" Value="KC Welcome Page" />
<Property Name="ContentTypeId" Value="0x010100C568DB52D9D0A14D9B2FDCC96666E9F2007948130EC3DB064584E219954237AF39001bb192640f8748d78db60217bd43598900ba17917e4d5348babd629f7ae8755a5e" />
<Property Name="PublishingPageContent" Value="Lorem &lt;strong&gt;ipsum&lt;/strong&gt; &lt;em&gt;test add&lt;/em&gt;" />


Hope it helps, C:\Marius

-
Unfortunately it doesnt do the trick. Now I can't deploy my solution, it says: "Error occurred in deployment step 'Activate Features': Failed to instantiate file "default.aspx" from module "DefaultHome": The specified list does not exist. " It's strange, because the feature's property Activate on Default is set to FALSE. –  Farrell Apr 23 '12 at 9:12
If you have already enabled the feature in a previous deployment it would reactivate it upon deployment (put the solution to No Activation to avoid it). You need NOT to have a File physically for this to work - just the Library prior created (assuming this is Publishing) - Pages should be. –  C. Marius - MVP Apr 23 '12 at 9:50
It's really weird but, when I activate the features by hand "SharePoint Server Publishing Infrastructure" and "SharePoint Server Publishing", and then install my Web Template it works like a charm. But the Web Template itself should do this automaticly. :( –  Farrell Apr 23 '12 at 11:41
That is because of Visual Studio, well-known behaviour! It caches a lot of files in order to do his job better, try closing it from time to time, and also try using CKS:Dev extensions, so you could triger IIS reset/WebApp pools recycle - that helps too. –  C. Marius - MVP Apr 23 '12 at 11:59
It still doesn't work. I suppose I have to choose another approach. –  Farrell May 3 '12 at 10:32

I think the issue is nothing to do with your custom feature, I used to get this error when in my site I already have some default list/library(Documents, Discussions etc) and I try to activate Team collaboration feature. I think in your case it could be that there is some list created by a feature and another feature is also trying to create list/library with the same name. Easy way is to remove all the features and add one by one, test the site creation process.

-