I have a generic feature, feature #1, that will be deployed to multiple site collections and will include some standard page layouts include one called OneColumn.aspx. I have another feature, feature #2 which will only be deployed to a single site collection and that will provision pages using page layouts from feature #1. How can I get this to work? Below is my attempted elements.xml file for feature #2:

<Module Name="Home Pages" Path="Pages">
    <File Type="GhostableInLibrary" Path="..\Framework\MasterPageGallery\Intranet\OneColumn.aspx" Url="Home_Pages/Welcome.aspx">

I try to use "..\" in my path so I can look over into the folder for feature #1 but this fails because of the illegal characters in the path. Are you not allowed to reference files outside of your current feature inside of the elements.xml?


Splitting them in two different features does not introduce any big complexity. If you deploy your layouts first, your 2nd feature can simple refer to them. However, from your file it seems you are trying to deploy a copy of your layout as your site page in your 2nd site collection? Site pages are not copies of layouts, they merely refer to them.

Here is how to deploy a site page that will use an existing layout:

<File Url="MyHomePage.aspx" Type="GhostableInLibrary">
    <Property Name="Title" Value="HomePage Title" />
    <Property Name="PublishingPageLayout" Value="~SiteCollection/_catalogs/masterpage/OneColumn.aspx, One Column Layout" />
    <Property Name="ContentType" Value="$Resources:cmscore,contenttype_enterprisewiki_name;" />

Edit the ContentType property to match whatever you associated your layout with. To deploy the layout itself you should have used:

<File Url="OneColumn.aspx" Type="GhostableInLibrary" IgnoreIfAlreadyExists="TRUE">
  <Property Name="Title" Value="One Column Layout" />
  <Property Name="UIVersion" Value="4" />
  <Property Name="ContentType" Value="$Resources:cmscore,contenttype_pagelayout_name;" />
  <Property Name="PublishingPreviewImage" Value="$PublishingPreviewImage$" />
  <Property Name="PublishingAssociatedContentType" Value=";#$Resources:cmscore,contenttype_enterprisewiki_name;;#0x010100C568DB52D9D0A14D9B2FDCC96666E9F2007948130EC3DB064584E219954237AF39004C1F8B46085B4d22B1CDC3DE08CFFB9C;#"/>     

Again adjusting the PublishingAssociatedContentType to the same CT as the ContentType property in the previous block.

One caveat to remember:

  • Since layouts are always deployed in the site collection root's _catalogs/masterpage gallery (even if you try to activate them in a subsite), they must be associated with a content type also at the root level. If not, it will deploy but will be unusable (will not have a valid CT association)

Finally, your site page itself (in your package) doesn't have to contain much. This should do it:

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

Why don't you create a single feature (preferably Site Collection level) containing all the page layouts, which will be provisioned upon feature activation, instead? This becomes much easier to maintain and extend.


Use the ~sitecollection to point to the site collection root at the start of the url instead of ../

  • The Path argument refers to the file inside the package. ~sitecollection is meaningless in that context. – Louis Feb 21 '12 at 3:50
  • My bad, overlook that part :-D – Colin Feb 21 '12 at 18:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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