{"id":54,"date":"2009-11-02T12:21:37","date_gmt":"2009-11-02T19:21:37","guid":{"rendered":"http:\/\/localhost\/todd_wp\/how-to-create-a-custom-site-definition-in-sharepoint-2010-aspx\/"},"modified":"2013-07-01T13:55:30","modified_gmt":"2013-07-01T19:55:30","slug":"how-to-create-a-custom-site-definition-in-sharepoint-2010-aspx","status":"publish","type":"post","link":"https:\/\/toddbaginski.com\/blog\/how-to-create-a-custom-site-definition-in-sharepoint-2010-aspx\/","title":{"rendered":"HOW TO: Create a custom site definition in SharePoint 2010"},"content":{"rendered":"<p><a class=\"retweet self\"><\/a><\/p>\n<p>\u00a0<\/p>\n<p>This article describes how to create a custom site definition in SharePoint 2010.\u00a0 The process to create a custom site definition has not changed much since the last version of SharePoint, the only differences are the directory names and some of the XML in the WEBTEMP files.\u00a0 See <a href=\"https:\/\/toddbaginski.com\/blog\/archive\/2007\/08\/16\/creating-a-custom-site-definition-in-wss-v3-moss.aspx\">this blog post<\/a> if you would like to see how this is done in WSS 3.0 \/ MOSS 2007.<\/p>\n<p><strong>Site Definition basics<\/strong><\/p>\n<p>Site definitions are located in the following folder on the SharePoint server: <\/p>\n<pre style=\"BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: &quot;Courier New&quot;, courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px\" id=\"codeSnippet\">C:Program FilesCommon FilesMicrosoft Sharedweb server <br \/>extensions14TEMPLATESiteTemplates <\/pre>\n<p>\nEach site definition has its own sub directory under this folder. <\/p>\n<p>Inside each site definition sub directory the .aspx pages for the various web pages and lists that make up the site definition are stored.\u00a0 Some of the new site definitions that come with SharePoint 2010 also include image files in these subdirectories.\u00a0 The ONET.XML file specifies the various configurations and modules the site definition is made up of.\u00a0 It is stored inside the XML subdirectory inside each site definition sub directory. <\/p>\n<p><strong>*Note: <\/strong>I think it is interesting that the SDK refers to Site Templates as the .stp files that are generated when you save a site as a template from the web UI, and the SDK refers to file based site templates as site definitions \u2013 yet this directory is named SiteTemplates.\u00a0 This has been the case for a couple of versions now so I don&#8217;t think we&#8217;ll see it change in the future. <\/p>\n<p>Site definitions are registered with SharePoint and made available via the WEBTEMP&lt;NAME OF SITE DEFINITION&gt;.XML file.\u00a0 Theoretically, you could register a site definition with SharePoint with one of the out of the box WEBTEMP XML files, however this could introduce problems when service packs or newer versions of the product are released.\u00a0 It is considered best practice to create your own WEBTEMP XML file to register your custom site definitions. <\/p>\n<p>WEBTEMP XML files are located in the following folder on the SharePoint server: <\/p>\n<pre style=\"BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: &quot;Courier New&quot;, courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px\" id=\"codeSnippet\">C:Program FilesCommon FilesMicrosoft Sharedweb server <br \/>extensions14TEMPLATE1033XML<\/pre>\n<p><\/p>\n<p><strong>Creating a custom Site Definition in SharePoint 2010 \u2013 Manual Approach<\/strong><\/p>\n<div>\n<div>\n<div>\n<div>\n<p>Step 1: Clone an existing Site Definition<\/p>\n<p>Step 2: Create the WEBTEMP XML fragment file to register the site definition with SharePoint<\/p>\n<p>Step 3: Reset the application pool<\/p>\n<p>Step 4: Create a site based on the custom site definition<\/p>\n<p><strong>Step 1: Clone an existing site definition<\/strong><\/p>\n<p>Navigate to the following directory on the SharePoint server in Windows Explorer:<\/p>\n<div id=\"codeSnippetWrapper\">\n<pre style=\"BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: &quot;Courier New&quot;, courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px\" id=\"codeSnippet\">C:Program FilesCommon FilesMicrosoft Sharedweb server <br \/>extensions14TEMPLATESiteTemplates<\/pre>\n<p>\n<\/div>\n<div id=\"codeSnippetWrapper\">Copy the STS directory and paste it back into the same directory.\u00a0 (You can copy any of the existing site definitions and use them as a baseline to create your own.)<\/div>\n<div>\u00a0<\/div>\n<p>Rename the Copy of STS directory to SAMPLE<\/p>\n<p><strong>Step 2: Create the WEBTEMP XML fragment file to register the site definition with SharePoint<\/strong><\/p>\n<p>Create a file called WEBTEMPSAMPLE.XML in the following directory:<\/p>\n<div id=\"codeSnippetWrapper\">\n<pre style=\"BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: &quot;Courier New&quot;, courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px\" id=\"codeSnippet\">C:Program FilesCommon FilesMicrosoft Sharedweb server <br \/>extensions14TEMPLATE1033XML<\/pre>\n<p>\n<\/div>\n<div><strong>Put the following XML into the WEBTEMPSAMPLE.XML file:<\/strong><\/div>\n<p><\/p>\n<div>\n<div>\n<div>\n<div id=\"codeSnippetWrapper\">\n<pre style=\"BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: &quot;Courier New&quot;, courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px\" id=\"codeSnippet\"><strong>&lt;?xml version=<span style=\"COLOR: #006080\">\"1.0\"<\/span> encoding=<span style=\"COLOR: #006080\">\"utf-8\"<\/span>?&gt;<br \/>&lt;!-- _lcid=<span style=\"COLOR: #006080\">\"1033\"<\/span> _version=<span style=\"COLOR: #006080\">\"14.0.4514\"<\/span> _dal=<span style=\"COLOR: #006080\">\"1\"<\/span> --&gt;<br \/>&lt;!-- _LocalBinding --&gt;<br \/>&lt;Templates xmlns:ows=<span style=\"COLOR: #006080\">\"Microsoft SharePoint\"<\/span>&gt;<br \/> &lt;Template Name=<span style=\"COLOR: #006080\">\"SAMPLE\"<\/span> ID=<span style=\"COLOR: #006080\">\"10001\"<\/span>&gt;<br \/>    &lt;Configuration ID=<span style=\"COLOR: #006080\">\"0\"<\/span> Title=<span style=\"COLOR: #006080\">\"Sample Team Site\"<\/span> Hidden=<span style=\"COLOR: #006080\">\"FALSE\"<\/span> <br \/>        ImageUrl=<span style=\"COLOR: #006080\">\"\/_layouts\/images\/stts.png\"<\/span> Description=<span style=\"COLOR: #006080\">\"A sample team site.\"<\/span> <br \/>        DisplayCategory=<span style=\"COLOR: #006080\">\"Custom Site Definitions\"<\/span> &gt;<br \/>    &lt;\/Configuration&gt;<br \/>    &lt;Configuration ID=<span style=\"COLOR: #006080\">\"1\"<\/span> Title=<span style=\"COLOR: #006080\">\"Sample Blank Site\"<\/span> Hidden=<span style=\"COLOR: #006080\">\"FALSE\"<\/span> <br \/>        ImageUrl=<span style=\"COLOR: #006080\">\"\/_layouts\/images\/stbs.png\"<\/span> Description=<span style=\"COLOR: #006080\">\"A sample blank site.\"<\/span> <br \/>        DisplayCategory=<span style=\"COLOR: #006080\">\"Custom Site Definitions\"<\/span> AllowGlobalFeatureAssociations=<span style=\"COLOR: #006080\">\"False\"<\/span> &gt;<br \/>    &lt;\/Configuration&gt;<br \/>    &lt;Configuration ID=<span style=\"COLOR: #006080\">\"2\"<\/span> Title=<span style=\"COLOR: #006080\">\"Sample Document Workspace\"<\/span> Hidden=<span style=\"COLOR: #006080\">\"FALSE\"<\/span> <br \/>        ImageUrl=<span style=\"COLOR: #006080\">\"\/_layouts\/images\/stdw.png\"<\/span> Description=<span style=\"COLOR: #006080\">\"A sample document workspace.\"<\/span> <br \/>        DisplayCategory=<span style=\"COLOR: #006080\">\"Custom Site Definitions\"<\/span> &gt;    <br \/>    &lt;\/Configuration&gt;<br \/> &lt;\/Template&gt; <br \/>&lt;\/Templates&gt;<\/strong><\/pre>\n<p>\n<\/div>\n<div id=\"codeSnippetWrapper\">*Note: The DisplayCategory attribute of the &lt;Configuration&gt; element dictates which tab the configuration will appear on in the create new site web dialog. You can create your own tabs by putting your own values in this attribute (like I have done in the XML above and displayed in the screenshot below).\u00a0 The screenshot below demonstrates how the Configuration element\u2019s attributes (inside the WEBTEMP file) map to the create a site dialog. <\/div>\n<div>\u00a0<\/div>\n<p><a rel=\"lightbox\" href=\"https:\/\/toddbaginski.com\/blog\/images\/www_toddbaginski_com\/blog\/WindowsLiveWriter\/CreatingacustomSiteDefinitioninSharePoin_AC69\/webtemp%20attribute%20mapping_2.png\"><strong><img loading=\"lazy\" decoding=\"async\" style=\"BORDER-RIGHT-WIDTH: 0px; DISPLAY: inline; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px\" title=\"WEBTEMP Configuration element attribute mapping diagram.\" border=\"0\" alt=\"WEBTEMP Configuration element attribute mapping diagram.\" width=\"604\" height=\"219\" src=\"https:\/\/toddbaginski.com\/blog\/images\/www_toddbaginski_com\/blog\/WindowsLiveWriter\/CreatingacustomSiteDefinitioninSharePoin_AC69\/webtemp%20attribute%20mapping_thumb.png\" \/><\/strong><\/a><strong> <\/strong><\/p>\n<p>Save the file.<\/p>\n<p><strong>Step 3: Reset IIS<\/strong><\/p>\n<p>Open a command prompt on the SharePoint server<\/p>\n<p>Type in the command: iisreset<\/p>\n<p>Wait for IIS to reset<\/p>\n<p><strong>Step 4: Create a site based on the custom site definition<\/strong><\/p>\n<p>Open Internet Explorer<\/p>\n<p>Navigate to a SharePoint site on the server where you performed the steps above.<\/p>\n<p>Click the Site Actions menu<\/p>\n<p>Select New Site<\/p>\n<p>Click the Custom Site Definitions tab on the left side of the create a site dialog to see the new site templates you registered with the SAMPLE site definition.\u00a0 <\/p>\n<p>Select one of the sample site templates you created.<\/p>\n<p>Enter a title and URL<\/p>\n<p>Click the Create button and your new SharePoint site is created.<\/p>\n<p><strong>Creating a custom Site Definition in SharePoint 2010 \u2013 Visual Studio 2010 Approach<\/strong><\/p>\n<p>Visual Studio 2010 simplifies the process by providing a project type specifically tailored for this purpose.\u00a0 To create a custom site definition with Visual Studio 2010 first create a new Site Definition project.\u00a0 See the screenshot below for reference.<\/p>\n<p><a rel=\"lightbox\" href=\"https:\/\/toddbaginski.com\/blog\/images\/www_toddbaginski_com\/blog\/WindowsLiveWriter\/CreatingacustomSiteDefinitioninSharePoin_AC69\/create%20vs%20site%20definition%20project_2.png\"><img loading=\"lazy\" decoding=\"async\" style=\"BORDER-RIGHT-WIDTH: 0px; DISPLAY: inline; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px\" title=\"Creating a Site Definition project type in VS 2010.\" border=\"0\" alt=\"Creating a Site Definition project type in VS 2010.\" width=\"600\" height=\"528\" src=\"https:\/\/toddbaginski.com\/blog\/images\/www_toddbaginski_com\/blog\/WindowsLiveWriter\/CreatingacustomSiteDefinitioninSharePoin_AC69\/create%20vs%20site%20definition%20project_thumb.png\" \/><\/a> <\/p>\n<p>Then set the path to the SharePoint site where you would like to deploy the site definition.<\/p>\n<p><a rel=\"lightbox\" href=\"https:\/\/toddbaginski.com\/blog\/images\/www_toddbaginski_com\/blog\/WindowsLiveWriter\/CreatingacustomSiteDefinitioninSharePoin_AC69\/set%20web%20site_2.png\"><img loading=\"lazy\" decoding=\"async\" style=\"BORDER-RIGHT-WIDTH: 0px; DISPLAY: inline; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px\" title=\"Set the site where you would like to deploy the custom site definition.\" border=\"0\" alt=\"Set the site where you would like to deploy the custom site definition.\" width=\"598\" height=\"475\" src=\"https:\/\/toddbaginski.com\/blog\/images\/www_toddbaginski_com\/blog\/WindowsLiveWriter\/CreatingacustomSiteDefinitioninSharePoin_AC69\/set%20web%20site_thumb.png\" \/><\/a> <\/p>\n<p>Once the project is created, you can see all the files needed to support a custom site definition in the Solution Explorer.<\/p>\n<p><a rel=\"lightbox\" href=\"https:\/\/toddbaginski.com\/blog\/images\/www_toddbaginski_com\/blog\/WindowsLiveWriter\/CreatingacustomSiteDefinitioninSharePoin_AC69\/vs%20site%20def%20sol%20explorer_2.png\"><img loading=\"lazy\" decoding=\"async\" style=\"BORDER-RIGHT-WIDTH: 0px; DISPLAY: inline; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px\" title=\"Solution Explorer showing the files which make up the Site Definition project.\" border=\"0\" alt=\"Solution Explorer showing the files which make up the Site Definition project.\" width=\"353\" height=\"228\" src=\"https:\/\/toddbaginski.com\/blog\/images\/www_toddbaginski_com\/blog\/WindowsLiveWriter\/CreatingacustomSiteDefinitioninSharePoin_AC69\/vs%20site%20def%20sol%20explorer_thumb.png\" \/><\/a> <\/p>\n<p>After you make edits to the files all you need to do is press F5 and the custom site definition is packaged into a WSP and deployed to the SharePoint server.\u00a0 All that is left to do is to create a new site based on the custom site definition to verify it works properly.\u00a0 <\/p>\n<p><a rel=\"lightbox\" href=\"https:\/\/toddbaginski.com\/blog\/images\/www_toddbaginski_com\/blog\/WindowsLiveWriter\/CreatingacustomSiteDefinitioninSharePoin_AC69\/vs%20generated%20site%20def_2.png\"><img loading=\"lazy\" decoding=\"async\" style=\"BORDER-RIGHT-WIDTH: 0px; DISPLAY: inline; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px\" title=\"How the custom SharePoint site template appears when made from the out of the box VS 2010 Site Definition project type.\" border=\"0\" alt=\"How the custom SharePoint site template appears when made from the out of the box VS 2010 Site Definition project type.\" width=\"600\" height=\"212\" src=\"https:\/\/toddbaginski.com\/blog\/images\/www_toddbaginski_com\/blog\/WindowsLiveWriter\/CreatingacustomSiteDefinitioninSharePoin_AC69\/vs%20generated%20site%20def_thumb.png\" \/><\/a> <\/p>\n<p>Here you can see what the site template looks like when you use the out of the box Visual Studio 2010 Site Definition project type.<\/p>\n<p><a rel=\"lightbox\" href=\"https:\/\/toddbaginski.com\/blog\/images\/www_toddbaginski_com\/blog\/WindowsLiveWriter\/CreatingacustomSiteDefinitioninSharePoin_AC69\/site%20made%20from%20vs%20site%20def%20project_2.png\"><strong><img loading=\"lazy\" decoding=\"async\" style=\"BORDER-RIGHT-WIDTH: 0px; DISPLAY: inline; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px\" title=\"SharePoint site made from out of the box VS 2010 Site Definition project type.\" border=\"0\" alt=\"SharePoint site made from out of the box VS 2010 Site Definition project type.\" width=\"600\" height=\"170\" src=\"https:\/\/toddbaginski.com\/blog\/images\/www_toddbaginski_com\/blog\/WindowsLiveWriter\/CreatingacustomSiteDefinitioninSharePoin_AC69\/site%20made%20from%20vs%20site%20def%20project_thumb.png\" \/><\/strong><\/a><strong> <\/strong><\/p>\n<p><strong>Wrap Up<\/strong><\/p>\n<p>There are several blog posts which discuss when and why you may want to create a custom site definition.\u00a0 Some folks are of the opinion it is something you should never do, other folks believe it makes sense to do it in certain situations.\u00a0 Personally, I believe they are a good solution when you need a new ID to staple features to.<\/p>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>\u00a0 This article describes how to create a custom site definition in SharePoint 2010.\u00a0 The process to create a custom site definition has not changed much<span class=\"excerpt-hellip\"> [\u2026]<\/span><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"om_disable_all_campaigns":false,"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[98],"tags":[10,5,6,7,13,12],"class_list":["post-54","post","type-post","status-publish","format-standard","hentry","category-sharepoint-2010","tag-custom-development","tag-helpful-code","tag-how-to-sharepoint","tag-sharepoint","tag-site-definitions","tag-site-templates"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/toddbaginski.com\/blog\/wp-json\/wp\/v2\/posts\/54","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/toddbaginski.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/toddbaginski.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/toddbaginski.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/toddbaginski.com\/blog\/wp-json\/wp\/v2\/comments?post=54"}],"version-history":[{"count":1,"href":"https:\/\/toddbaginski.com\/blog\/wp-json\/wp\/v2\/posts\/54\/revisions"}],"predecessor-version":[{"id":813,"href":"https:\/\/toddbaginski.com\/blog\/wp-json\/wp\/v2\/posts\/54\/revisions\/813"}],"wp:attachment":[{"href":"https:\/\/toddbaginski.com\/blog\/wp-json\/wp\/v2\/media?parent=54"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/toddbaginski.com\/blog\/wp-json\/wp\/v2\/categories?post=54"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/toddbaginski.com\/blog\/wp-json\/wp\/v2\/tags?post=54"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}