This post is a sequel to the article Deploying Publishing Page Layouts and Pages Using Features in which we examined the step-by-step process of deploying publishing pages based on a page layout using SharePoint features. As we saw, apart from a few caveats, that approach was quite straightforward and beneficial, allowing us to easily move a solution between environments.
However, the previous solution had one disadvantage – the page layout and the publishing page itself were deployed within the same feature. While this works for our small sample, it is not the cleanest approach for a real-life project.
In an end-user solution it is better to package page layouts in one feature and publishing pages in another. This way we are able to deploy content separately to development or QA environments for testing purposes and a clean solution without content to production.
In the end we would like to re-structure the solution to look like this:
In this post we go through the step-by-step process of creating a SharePoint solution that deploys a publishing page layout and a publishing page for press releases. Provisioning page layouts and pages using features and solution packages (*.wsp) allows for improved code reuse and makes it easier to move the solution between environments (development, testing, staging, and production).
As a matter of fact, there are already quite a few examples on the web that cover the topic of creating a SharePoint 2010 publishing page layout in Visual Studio 2010. One particularly good article is posted from Becky Bertram on her blog here.
However, in a recent project of ours, we also needed to deploy publishing pages together with the page layout, and after coming up with the solution, we decided to share our experience. The SharePoint Developer Tools in Visual Studio 2010 do not include specific project item templates for doing this, but it can be achieved using the module item template.
Here is how our solution will look like when we are done:
Please note that in order to successfully deploy the solution the target SharePoint site should be a publishing site.