# Provisioning Publishing Page Content using a Feature

I'm provisioning a bunch of Publishing pages using a feature, using the template redirection technique.

<Module Name="Page-Not-Found" Url="\$Resources:cmscore,List_Pages_UrlName;">
<File Url="Page-Not-Found.aspx" Path="Root\template.aspx" Type="GhostableInLibrary">
<Property Name="PublishingPageLayout" Value="~SiteCollection/_catalogs/masterpage/MyPageLayout.aspx, My Page Layout Name" />
<Property Name="ContentType" Value="My Content Type Name" />
</File>
</Module>


The pages are provisioned correctly:

• The Title property is set correctly
• The page is created using the appropriate page layout and is bound to the correct content type
• It's not shown here, but I can also use AllUsersWebPart to provision web parts onto the page

The problem I'm having is that I'm unable to populate the Html fields on the page with content; for example, by adding a property like:

<Property Name="PageContent1" Value="&lt;h1&gt;Page Not Found&lt;/h1&gt;&lt;p&gt;Sorry, that page doesn&#39;t exist.&lt;/p&gt;"/>


I tried some alternate syntax, such as:

<Property Name="PageContent1">
</Property>


but that didn't work either. The field PageContent1 is always empty, and I see no errors in the logs.

I only see this issue for HTML fields like PageContent1. I'm using the same technique to set the value of a Lookup Column and Note field on the page and have no problems there.

Is anybody using this technique to provision Publishing pages and populate them with content?

Thank you

-
Is the Html field built in, or one you provisioned as part of a content type for a page layout? –  James Love Dec 6 '11 at 19:09
I believe it should render the content. I would suggest double check the field name, make sure you are using internal name and then delete the page and reactivate the feature. –  Ashish Patel Dec 6 '11 at 19:17
James, PageContent1 is an HTML field that's part of the content type associated with the page. –  George Durzi Dec 6 '11 at 22:02
Ashish, the page is created as part of a feature. –  George Durzi Dec 6 '11 at 22:18

When provisioning Publishing Pages, you need to load an instance of the Template Redirection Page (found under SiteTemplates\SPS\default.aspx), but set the Url for the page to the name that you want to create, and set the properties such as content type and page layout in the normal way.

Have a look at this for an example: http://stefan-stanev-sharepoint-blog.blogspot.com/2010/07/provision-publishing-pages-in-sandbox.html

But modify the Feature Module to look like this:

<Module Name="MyPages" SetupPath="SiteTemplates\SPS" Url="Pages">
<File Url="Page-Not-Found.aspx" Path="default.aspx" Type="GhostableInLibrary">
<Property Name="ContentType" Value="My Content Type Name" />
<Property Name="PublishingPageLayout" Value="~SiteCollection/_catalogs/masterpage/MyPageLayout.aspx, My Page Layout Name" />
</File>
</Module>

-
James, let me try that. I'm using the Template Redirection page, but I actually have a copy of it in my feature. –  George Durzi Dec 6 '11 at 22:03
James, this worked great. Thank you. It's strange that it wasn't working before because I was using my own copy of the Template Redirection Page (which I now know that I don't need). Thanks again. –  George Durzi Dec 6 '11 at 22:58
It's more to do with where the Feature gets the file (see the SetupPath attribute of Module). For some reason it never likes it when you try and pick a custom template file. –  James Love Dec 7 '11 at 7:47