Wednesday, February 10, 2010

How to deploy Custom Masterpage

How to deploy Custom Masterpage

Masterpage could be customized through Sharepoint Designer. But sometimes developer need to deploy Custom Masterpage with Solution WSP package.

Custom Masterpage could be inluded into solution in an easy way. In Masterpage could be customized especially contentplaceholders, could be attached custom css styles, custom javascript codes, etc.

In this article i will describe how to deploy Custom Masterpage within WSP Solution package.

You should follow these steps:
  1. Create a Blank Site Definition
  2. Attach Custom Masterpage to solution
  3. Update Site definition
  4. Deploy solution and create Site collection

1) Create a Blank Site Definition

- in Menu choose: File -> New -> Project
- in tree list navigate to Sharepoint group and choose Blank Site Definition
- fill the Name and Location of project
- click OK

creating blank site definition

2) Attach Custom Masterpage to solution

- locate file default.master in folder: C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\12\TEMPLATE\GLOBAL\default.master
- right click the file and choose Copy
- go to visual studio solution explorer
- right click the folder Site definition under the created project
- choose Paste from context menu
- right click the inserted file default.master and choose Rename
- set the name of file to: demosite.master

3) Update Site definition

- locate and open for update onet.xml file in solution explorer
- navigate to Configuration node with ID=1 under Configurations node
- add attributes CustomMasterUrl and MasterUrl as shown on picture:

updating site definition
- XML code for copy:









- navigate to Modules node under the edited Configuration node
- create new reference Module node under Modules node as shown on picture
- navigate to Modules node under Project node
- create new definition Module node as shown on picture:

updating site definition
- XML code for copy:





4) Deploy solution and create Site collection

- when you have attached customized master page to solution package, next step are common for most deployment scenarious, just deploy solution and create site collection
- after you done it, site should be displayed with custom master page:

custom masterpage
Custom Masterpage was deployed successfuly with solution WSP package.

Back to Top