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
- Open Visual Studio.
- Open "New Project" dialog box. Expand Office/SharePoint node and choose SharePoint Solutions.
- Select "SharePoint 2013 – Empty Project" template. Name the project as CustomSharePointProject.
![]()
- Choose the "Deploy as a farm solution" radio button (because site definition can be added to the form solutions only) and click Finish.
![]()
- “CustomSharePointProject” SharePoint project has been created successfully.
![]()
Create Site Definition
- Right click on CustomSharePointProject -> Add -> New Item.
![]()
- Add Site Definition (form solution only) from the "Add New Item" window. Name it as “MySiteDefinition”.
![]()
- MySiteDefinition has got created in the following folder structure.
![]()
- Create new list definition, content type, event receiver, etc. in the SharePoint project. For example, create new list definition as follows.
- Right click on CustomSharePointProject -> Add -> New Item.
![]()
- Add List from the "Add New Item" window. Name it as “MyCustomList”.
![]()
- Select customizable list template and choose Default (Custom list).
![]()
- List definition has been created.
![]()
- Open onet.xml file of Site definition.
![]()
- 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).
![]()
- Build and deploy the SharePoint Solution.
- Go to SharePoint site, Site Actions -> Site Content -> New Subsite.
![]()
- Our custom Site definition will appear under “SharePoint Customizations” tab. Create new subsite with “MySiteDefinition” as template.
![]()
- New subsite got created with custom Site definition.
![]()
- 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.