Steps To Create Custom Site Definition In SharePoint 2013 Using Visual Studio

Introduction

SharePoint site definition serves as a foundation to the new SharePoint site. Site definition determines the appearance, behavior, default content (lists, content types, event receivers, images, etc.), and functionality of the SharePoint site. In this article, I will explain how to create custom Site Definition in SharePoint 2013, using Visual Studio.

Pre-requisites

  1. Open Visual Studio.
  2. Open "New Project" dialog box. Expand Office/SharePoint node and choose SharePoint Solutions.
  3. Select "SharePoint 2013 – Empty Project" template. Name the project as CustomSharePointProject.



  4. Choose the "Deploy as a farm solution" radio button (because site definition can be added to the form solutions only) and click Finish.



  5. “CustomSharePointProject” SharePoint project has been created successfully.



Create Site Definition

  1. Right click on CustomSharePointProject -> Add -> New Item.



  2. Add Site Definition (form solution only) from the "Add New Item" window. Name it as “MySiteDefinition”.



  3. MySiteDefinition has got created in the following folder structure.



  4. Create new list definition, content type, event receiver, etc. in the SharePoint project. For example, create new list definition as follows.

  5. Right click on CustomSharePointProject -> Add -> New Item.



  6. Add List from the "Add New Item" window. Name it as “MyCustomList”.



  7. Select customizable list template and choose Default (Custom list).



  8. List definition has been created.



  9. Open onet.xml file of Site definition.



  10. Add your custom List definition to the <list> tag in onet.xml file. Give proper List template type and feature id (Take from default feature created).



  11. Build and deploy the SharePoint Solution.

  12. Go to SharePoint site, Site Actions -> Site Content -> New Subsite.

  13. Our custom Site definition will appear under “SharePoint Customizations” tab. Create new subsite with “MySiteDefinition” as template.


  14. New subsite got created with custom Site definition.


  15. Go to Site Action -> Site Content in the newly created site. Our custom List got created in the subsite.


Summary

Thus, you learned how to create custom Site Definition in SharePoint 2013, using Visual Studio.

Up Next
    Ebook Download
    View all
    Learn
    View all