in

SharePoint Blogs

The Best Place for SharePoint-related Blogs

Todd Baginski's SharePoint 2003 and MOSS 2007 Blog

Creating a custom Site Definition in WSS V3 / MOSS

This is a repost of an article that was lost due to a server crash.

The new version 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 Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\SiteTemplates

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 Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\1033\XML

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 Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\SiteTemplates

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 Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\1033

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 Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\1033\XML

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.

Comments

 

Michael said:

Thank you!

December 13, 2007 7:00 AM
 

praveen said:

i am gettting the following error.

Failed to activate site-scoped features for template 'SAMPLE#0' in site http://mysite/custom/

Object reference not set to an instance of an object.

please help me out.

thanks

December 15, 2007 7:39 AM
 

praveen said:

for other templates,

sample blank site, it is giving errror

site template SAMPLE#1 is not found

sample Document workspace, it is giving errror

site template SAMPLE#2 is not found

December 15, 2007 7:45 AM
 

Ved said:

Hi

I successfully created the site definition. But when I modify the master page in SPD, i can not create the site with new template. Rather I get the error : "File not found".

Can somebody suggest me please?

Thanks

February 6, 2008 7:23 AM
 

nrao said:

nice article. Thanks.

February 13, 2008 3:24 PM
 

MH said:

Hey guys

So once that tab is created (the custom tab), how do you change it from saying "Custom" ?

Let me clarify, I know how to change it if you add a site definition. How do you change it though if you deplayed a site template to a site collection?

February 27, 2008 10:13 AM
 

paromita said:

thank you so much

March 3, 2008 8:45 AM
 

Obieg Dokumentow said:

Great post,

Thx!

March 10, 2008 5:16 PM
 

BushidoShonin said:

Great post

I was just wondering if there is a way to setup a site definition that created a specific document library. Any help help would be greatly apreciated.

Thanks

March 13, 2008 9:36 AM
 

Maik’s Blog » Blog Archive » Inserting initial information in a site definition said:

Pingback from  Maik&#8217;s Blog  &raquo; Blog Archive   &raquo; Inserting initial information in a site definition

March 26, 2008 11:49 AM
 

Maik’s Blog » Blog Archive » Inserting initial information in a site definition said:

Pingback from  Maik&#8217;s Blog  &raquo; Blog Archive   &raquo; Inserting initial information in a site definition

March 26, 2008 12:10 PM
 

Maik’s Blog » Blog Archive » Inserting initial information in a site definition said:

Pingback from  Maik&#8217;s Blog  &raquo; Blog Archive   &raquo; Inserting initial information in a site definition

March 27, 2008 6:19 AM
 

Internet Business Training Program said:

Almost all the internet marketing guru are almost doing the same thing. But just some are really the best of them all.

March 31, 2008 3:54 PM
 

Anthony said:

File not found :(

May 9, 2008 1:10 PM
 

Bill said:

MH,

Look for the DisplayCategory field at the end of your template in the WEBTEMP.XML file.

You can change this field to any value you would like and it will create a new display category if it is not already made.

DisplayCategory="What you want your category named"

May 14, 2008 12:54 PM
 

chanti said:

Very gud article..enough explanation,

May 26, 2008 11:23 PM
 

Saurabh said:

Hi Todd......a very nice article .....but this creates only Team Site.........but at my side there is a problem......i m creating Site Template using Features.......can u plz expain us how can we create Portal SiteTemplates....?

June 9, 2008 1:38 AM
 

Elka said:

Hi Todd... I have to design a site that willhelp organize SLAs and track monthly tasks for them in a compnay. I thought of using document workspaces to create a workspace for each SLA, and keep track of incidents and tasks within the workspace. Is there any chance one could customize the DWS template (create ones own, new) and mak it work for documents with "create document workspace feature".

June 13, 2008 5:03 AM
 

reset site definition said:

Pingback from  reset site definition

August 3, 2008 3:01 AM
 

Working With Site Definition « Vishal Varshney’s Weblog said:

Pingback from  Working With Site Definition &laquo; Vishal Varshney&#8217;s Weblog

August 8, 2008 12:59 AM
 

Mirrored Blogs said:

Body: I often get asked about the pros and cons of using SharePoint Designer versus custom site definitions

August 18, 2008 8:02 PM
 

Brijesh said:

Brilliant Tutorial

September 4, 2008 9:39 AM

Leave a Comment

(required )  
(optional )
(required )  
Add

About tbaginski

Todd began working with WSS and SPS in the beta stages of the products, in 2003. He has architected and implemented intranets, extranets, wireless deployments, and several custom applications with the WSS and SPS platforms. Todd created the first SharePoint advanced development training curriculum in the training industry for Microsoft SharePoint Portal Server 2003 and taught his first class in December of 2003. Todd also created the first advanced development training curriculum for Microsoft Office SharePoint Server (MOSS) 2007 and taught parts of this curriculum while MOSS was still in the Beta 1 Technical Refresh stage! Two versions in a row, Todd has broken ground in the training industry by being the first to offer advanced development training for SharePoint! Todd speaks at many SharePoint conferences including SharePoint Connections, the MS SharePoint Conference, and the upcoming TechEd 2008 Developers Conference. He has also spoken at Microsoft events at the Microsoft offices in both Denver, Colorado and Minneapolis, Minnesota. He has also presented several sessions at the Rocky Mountain SharePoint User's Group. He enjoys spending time with his wife and their dogs, playing and coaching lacrosse, playing hockey, riding his bike in the Rocky Mountains, and skiing every chance he gets.

Need SharePoint Training? Attend a SharePoint Bootcamp!

Posts (c) their respective authors. Everything else (c) 2007 SharePoint Experts