Wednesday, February 25, 2015

Create a Custom Master Page for SharePoint 2013 for Teams/Publishing Site Collection



I have successfully created a custom masterpage for SharePoint 2013 using Visual Studio 2013. Here are the steps I did to create my custom masterpage:Open the 15 hive to directory "15\TEMPLATE\GLOBAL"
  1. Copy the "seattle.master" file (or the oslo.master file)
  2. Create a new directory on your C: and paste the file
  3. Rename the file to anything you want. (i.e. seatle_k.master)
  4. Open Visual Studio 2013
  5. Create a new empty project
  6. Add a new module (2 files are created inside the module automatically.)
  7. Change the name of the module (i.e. ModuleMP)
  8. Delete the sample.txt file that was created automatically by adding the module
  9. Add an existing file to the module. Browse to your new seatle_k.master file and add it.
  10. Open the elements.xml file in the module.
  11. Change the <Module ...> by adding "List=116" and Url="_catalogs/masterpage"
  12. Change the <File ...> by adding Type="GhostableInLibrary"

    <?xml version="1.0" encoding="UTF-8"?>
    <Elements xmlns="http://schemas.microsoft.com/sharepoint/">
    <Module Url="_catalogs/masterpage" List="116" Name="ModuleMP">
    <File Url="ModuleMP/seattle_kcpl.master" Type="GhostableInLibrary" Path="ModuleMP\seattle_k.master"/>
    </Module>
    </Elements>

  13. Change the name of "Feature1" to something more useful (i.e. K_Feature1)
  14. Double click on Feature1 (now K_Feature1) and add custom text to the title and description.
  15. Double check that the project will deploy to the correct site collection URL by checking the "Site URL"
  16. Build your project
  17. Deploy your project
  18. Assuming everything went well your project should be successfully deployed.
    (In my case it errored out with "unable to activate feature". then I created the package wsp and deployed with powershell, Add-SPSolution then manually deployed it from Central Admin.)

    If this is a publishing site collection, you can change the new masterpage from Site Settings -->Master page and Page layout under look and feel. If this is Team Site Collection then pls follow the below steps.
  19. Open the destination site collection and go to the site settings. Check site features and double check that the solution was added and automatically activated.
  20. Open SharePoint Designer 2013
  21. Open the destination site where you deployed your new acme.master file
  22. In the left-hand vertical navigation in SPD click on the link "Master Pages"
  23. You should see your new acme.master file in the list
  24. Right-click on the acme.master file and click link "Set as Default Master Page"
  25. Ignore and click 'OK' when a pop-up message telling you that there is no associated html file to your masterpage.
  26. Navigate to your destination site in Internet Explorer to see your new masterpage


No comments:

Post a Comment