Deploy Master Page and Page layout as a feature
Posted by chrissyz on September 24, 2008
The following is the detailed the instructions of how to deploy Master Page and Custom Page Layout together
1. The following is the directory structure which I suggest when creating your own features
2. Under the PageLayouts folder you will see two files:
· MoscowLayout.aspx: this page is the custom page layout you created
· MoscowLayout.xml: this is the manifest files that identifies your custom page layout
You can put as much as custom page layout pages as you want in this folder, but you only need
one manifest file
3. The content of MoscowLayout.xml should be looks like:
<Elements xmlns=”http://schemas.microsoft.com/sharepoint/” >
<Module Name =”MOSCOWPageLayouts” Url =”_catalogs/masterpage”
Path =”PageLayouts” RootWebOnly =”TRUE”>
<File Url =”MoscowLayout.aspx” Type =”GhostableInLibrary”>
<Property Name =”Title” Value=”XXX”/>
<Property Name =”MasterPageDescription” Value=”XXX”/>
<Property Name =”ContentType” Value =”$Resources:cmscore,contenttype_pagelayout_name;”/>
<Property Name=”PublishingPreviewImage” Value =”~SiteCollection/_catalogs/masterpage/$Resources:core,Culture;/Preview Images/ArticleLeft.png, ~SiteCollection/_catalogs/masterpage/$Resources:core,Culture;/Preview Images/ArticleLeft.png”/>
</File>
</Module>
</Elements>
Module: indicate to SharePoint the location of the aspx pages. MoscowLayout.aspx is part of your feature and must be copied along with all of the other parts to the features folder. During the activation of your feature, it will be dropped in the Master Page and Page Layout gallery.
File: defines the path to your page and the type. GhostableInLibrary tells SharePoint to create a list item to go with your file when it is added to MasterPage and Page Layout gallery. Ghostable is used if you are provisioning a file outside a document library
Two important properties:
ContentType: OOTB Master Page Gallery has two content type associated with it. The value will either be master page or page layout.
Publishing AssociationConetentType: Specify ContentType to which your custom page layout is associated. The value of this one is composed of the name of your content type and the ID of content type. If this value is omitted, by default your layout will be associated with the basic ‘Page’ content type from the publishing feature
4. You put your master page, css file into MoscowMasterPage. The wollongongmaster.xml manifest file should look like the following:
<Elements xmlns=”http://schemas.microsoft.com/sharepoint/”>
<Module Name=”MasterPages” List=”116″ Url=”_catalogs/masterpage”>
<File Url=”Moscow.master” Type=”GhostableInLibrary” />
</Module>
<Module Name=”WollongongStyles” Url=”Style Library” RootWebOnly =”TRUE”>
<File Url=”Moscow.css” Type =”GhostableInLibrary”/>
</Module>
</Elements>
5. Under the folder MoscowFeature, you will see Feature.xml, it will look similar to
<Feature Id=”{6EAA33DF-AD39-4a2c-B5AB-972A576D7CF4}”
Title=”Moscow Branding”
Description=”Master Page and page layouts for Moscow”
Version=”1.0.0.0″
Scope=”Site”
Hidden=”FALSE” xmlns=”http://schemas.microsoft.com/sharepoint/“>
<ElementManifests>
<ElementFile Location=”PageLayouts\MoscowLayout.aspx”/>
<ElementManifest Location=”PageLayouts\MoscowLayout.xml” />
<ElementManifest Location =”MoscowMasterPage\wollongongmaster.xml”/>
</ElementManifests>
</Feature>
It contains ElementManifest files for master page and page layout.
This is just an example to give you a general idea of how custom page layout should be deployed. It depends on how individual elements are structured. And install.bat file is important as well because you need to copy the files to the right location in your 12 hives.





Aze said
Hello Chris,
I really enjoyed your articles. Just want to thank you for sharing your experience.
Regards,
Aze
chrissyz said
Hi Aze,
Thanks for the encouragement. Glad you like it.:)
Feel free to let me know if you have any specific interested topic that you want to know more.
Cheers,
Chris
Ken said
Hi Chris,
This is really a great article for me as I am still a rookie in SharePoint.
If my pagelayout has associated with a custom site content type, how could I define the site content type. I am developing a couple of page layouts in my development environment and I would like to deploy it to my production server. How could I archieve it.
Appreciate your help
Thanks
christopher said
Ken –
To associate a content type with a layout, you have to define a content type inside an Elements tag of a feature. Here are some useful links:
Deploying Content Types as Features
Content Type Definition Schema
Inside a ContentType node of xml, there is a DocumentTemplate node to associate that content type with a layout. Unfortunately I have not been able to get this working properly at the moment.
(note – I am not the Chris who authored this blog)
Update Master Page Gallery in Publishing site « Chintan Jajal said
[...] http://blogs.msdn.com/syedi/archive/2008/08/01/custom-site-definition-for-collaboration-portal-template-sharepoint-2007-wow-moss.aspx http://spreflections.wordpress.com/2008/09/24/deploy-master-page-and-page-layout-as-a-feature/ [...]