Adding a Document Library Feature to a Site Definition in WSS V3 / MOSS 2007
August 16, 2007
Creating and deploying VSTO Documents inside SharePoint Document Libraries
August 16, 2007

Update 11-22-2009:  See this blog post if you would like to see how to do this in SharePoint 2010.

The new version WSS 3.0 / MOSS 2007) of SharePoint brings some changes to the way Site Definitions are created and deployed to a SharePoint server. Additionally, the way Site Definitions are now architected has changed with the advent of Features. Although FrontPage 2003 has been significantly enhanced to become the Office SharePoint Designer, Features allow for more flexible deployments of functionality within SharePoint, and Master Pages allow us to change the look and feel of many sites inside SharePoint with a single click of a button custom Site Definitions can still be leveraged to provide outstanding enterprise wide flexibility and ease of maintenance for SharePoint sites.

Site Definitions are a complex and large topic that we will not delve into in an in depth manner right now. The purpose of this document is to describe how to create a custom Site Definition in order to set the stage for the other documentation.

Site Definition basics

Site Definitions are located in the following folder on the SharePoint server:

C:Program FilesCommon FilesMicrosoft Sharedweb server extensions12TEMPLATESiteTemplates

Each Site Definition has its own sub directory under this folder.

Inside each Site Definition sub directory the aspx pages for the various web pages and lists that make up the Site Definition are stored. The ONET.XML file that specifies the various configurations and modules the Site Definition is made up of is stored inside the XML subdirectory inside each Site Definition sub directory.

*Note: 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 – yet this directory is named SiteTemplates.

Site Definitions are registered with SharePoint and made available via the WEBTEMP<NAME OF SITE DEFINITION>.XML file.

These files are located in the following folder on the SharePoint server:

C:Program FilesCommon FilesMicrosoft Sharedweb server extensions12TEMPLATE1033XML

Creating a custom Site Definition in MOSS 2007

The following tasks are all you need to do to create a custom Site Definition in MOSS 2007.  

Step 1: Clone an existing Site Definition.

Step 2: Create the WEBTEMP XML fragment file to register the Site Definition with SharePoint.

Step 3: Reset IIS

Step 4: Create a site based on the custom Site Definition.

Step 1: Clone an existing Site Definition.  

Navigate to the following directory on the SharePoint server in Windows Explorer:

C:Program FilesCommon FilesMicrosoft Sharedweb server extensions12TEMPLATESiteTemplates

Copy the STS directory and paste it back into the same directory.

Rename the Copy of STS directory to SAMPLE

Navigate to the following directory on the SharePoint server in Windows Explorer:

C:Program FilesCommon FilesMicrosoft Sharedweb server extensions12TEMPLATE1033

Copy the STS directory and paste it back into the same directory.

Rename the Copy of STS directory to SAMPLE

Step 2: Create the WEBTEMP XML fragment file to register the Site Definition with SharePoint.  

Create a file called WEBTEMPSAMPLE.XML in the following directory:

C:Program FilesCommon FilesMicrosoft Sharedweb server extensions12TEMPLATE1033XML

Put the following XML into the WEBTEMPSAMPLE.XML file:

<?xml version=”1.0″ encoding=”utf-8″ ?>

<!-_lcid=”1033″ _version=”12.0.4017″ _dal=”1″ –>

<!-_LocalBinding –>

<Templates xmlns:ows=”Microsoft SharePoint”>

<Template Name=”SAMPLE” ID=”10001″>

<Configuration ID=”0″ Title=”Sample Site” Hidden=”FALSE” ImageUrl=”/_layouts/images/stsprev.png” Description=”This sample template creates a site for teams to create, organize, and share information quickly and easily. It includes a Document Library, and basic lists such as Announcements, Calendar, Contacts, and Quick Links.” DisplayCategory=”Custom Site Definitions” > </Configuration>

<Configuration ID=”1″ Title=”Sample Blank Site” Hidden=”FALSE” ImageUrl=”/_layouts/images/stsprev.png” Description=”This sample template creates a Windows SharePoint Services-enabled Web site with a blank home page. You can use a Windows SharePoint Services-compatible Web page editor to add interactive lists or any other Windows SharePoint Services features.” DisplayCategory=”Custom Site Definitions” > </Configuration>

<Configuration ID=”2″ Title=”Sample Document Workspace” Hidden=”FALSE” ImageUrl=”/_layouts/images/dwsprev.png” Description=”This sample template creates a site for colleagues to work together on documents. It provides a document library for storing the primary document and supporting files, a Task list for assigning to-do items, and a Links list for resources related to the document.” DisplayCategory=”Custom Site Definitions” > </Configuration>

</Template>

</Templates>  

*Note: The DisplayCategory attribute of the <Configuration> element dictates which tab the configuration will appear on in the Template Selection section of the create site web page. You can create your own tabs by putting your own values in this attribute (like we have done here).

Save the file.

Step 3: Reset IIS

Open a command prompt on the SharePoint server.

Type in the command: iisreset

Wait for IIS to reset

Step 4: Create a site based on the custom Site Definition.  

Open Internet Explorer

Navigate to the Sites Directory in your SharePoint portal (http://SharePointServerName/SiteDirectory)

Click the Create Site Link

Fill out the information on the form.

Notice at the bottom of the page in the Template Selection section the new Custom Site Definitions tab.

Click this tab and select one of the available configurations.

Click the Create button.