Chris’s SharePoint Reflections

Just another weblog

  • Chris Zhong

    IT consultant Australia

  • Advertisements

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=”” >

                <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”/>






 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=””&gt;

                <Module Name=”MasterPages” List=”116″ Url=”_catalogs/masterpage”>

                                <File Url=”Moscow.master” Type=”GhostableInLibrary” />


                <Module Name=”WollongongStyles” Url=”Style Library” RootWebOnly =”TRUE”>

                                <File Url=”Moscow.css” Type =”GhostableInLibrary”/>




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”



                Hidden=”FALSE” xmlns=”“>


                                <ElementFile Location=”PageLayouts\MoscowLayout.aspx”/>

                                <ElementManifest Location=”PageLayouts\MoscowLayout.xml” />

                                <ElementManifest Location =”MoscowMasterPage\wollongongmaster.xml”/>




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.



11 Responses to “Deploy Master Page and Page layout as a feature”

  1. Aze said

    Hello Chris,

    I really enjoyed your articles. Just want to thank you for sharing your experience.


  2. 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.


  3. 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


  4. 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)

  5. […] […]

  6. Bhargavi said

    Hello Chris,

    i am facing one issue, i have deployed the page layout as a feature and it is ghostable in librbary. If i go and modify the page layout like add another control or a webpart zone, the existing page created using that page layout doesnt not reflect the change. Even if i create a new page, the changes are not reflected there also. Any help??


  7. Ketan said

    Hello Chrissyz,

    Really liked your article, it helped a lot.
    Thanks for posting such a useful article.

    Also i would like to know that after deactivating the feature how the master page and layouts page gets deleted from the master page gallery.

    Is there any way to do this.

    Please reply back.

    Warm Regards,
    Ketan Gandhi

  8. John Developer said

    here is a tutorial on how to attach custom codebehind to masterpage. take a look on it,
    http://sharepoint-darius.blogspot.comCustom Masterpage

  9. Dmitry said

    Nice to see Moscow 🙂 example in this post. And additional, this link about changing Layout and Publish Page via after feature activating.

  10. nihar said

    I tried the same without master page(Only for layout),
    But it is not working..
    After activating the feature inside Create Page i am not getting my custom page 😦
    please help me out

  11. nihar said

    I removed the old .aspx file from galleries and then activated the worked 🙂
    thanks for the nice post

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: