Getting Started with Site Definitions

Site Definitions allow you to create you own sites templates that can be selected when creating new sites and contain their own lists/document libraries/webparts/features. (see image below) I'm going to show you how to quickly and easily create your own Site Definition from an existing Site Definition. If you want to add default functionality to your custom site definition, visit my post on Feature Stapling.



The first thing that you'll want to do is create your own copy of an existing site template. To do this, go to the 12 Hive's TEMPLATE\SiteTemplates folder. In here, we're going to create a copy of the sts folder and rename the copy SHAREPOINTLESSONS. (I recommend you use all caps to make it semi-consistent with the rest of the folders; however, your site will work if you use lowercase or mixed case.)



Next, you'll want to go to the TEMPLATE\1033\XML folder. (1033 for English. For other languages, use the appropriate LCID. If you have multiple LCID's in your TEMPLATE folder, here is a chart to help you find the appropriate one.)



In this folder, create a new copy one of the webtemp xml files and rename it. In this example, I've renamed mine WEBTEMPSPL.xml.





The following image contains the contents of WEBTEMPSPL.xml before I edit it. As you can see, the format is as follows:

















I'm going to remove all of the Template elements and create my own. First, create your new Template element and give it a Name attribute, as well as an ID attribute. The name that you use here must be the name of the new folder you created in the SiteTemplates directory. In this example, my template name must be SHAREPOINTLESSONS. As for the ID, it is recommended that you use a number above 10,000 to avoid conflicting with any ID's that Microsoft may already be using. My ID is 10002 (I've already used 10001).



Now we'll move on to the Configuration element. This one has 6 attributes that will need to be provided.


  1. ID - Unique ID for this particular configuration

  2. Title - Name that will appear for in the list box when users are creating new sites

  3. Hidden - Duh

  4. ImageUrl - Image displayed to the left of the listbox when you select this item

  5. Description - Text that appears beneath the image when you select this item

  6. DisplayCategory - Tab that this item will appear under



Once you are done filling in those attributes, save your xml file and run an IISReset. Now, when you go to create a new site, if you've followed this example to the letter, you'll see a new tab called "Custom SPL Templates" in the Template Selection Section. When you click on that tab, you'll see "SharePointLessons Site" which came from the Title attribute in the Configuration. To the left, you'll see the image that I specified in the configuration and just below the image you'll see the description.


So as you can see, its not difficult to get started. Now, if you want, you can go in and create a ton of features and "staple" them to your new Site Definition so that future uses of your Site Definition will contain default functionality. Here's a link for a lesson in Feature Stapling.

Labels: ,