429
15
Site Definitions and Templates
SharePoint provides a templating architecture that allows you to create a def-
inition of a site and to use this definition as the template from which to cre-
ate new sites. The site definition defines the components that make up a site,
such as the navigational structure, the welcome page, Web Parts that appear
on provisioned pages, and the document libraries and lists that are activated
upon site creation. This templating architecture, first introduced by Share-
Point Team Services and carried forward to SharePoint Portal Server 2003,
still plays an important role in SharePoint Server 2007. The structure and
content of site definitions have been considerably optimized in SharePoint
Server 2007, making them much easier to work with. This optimization is
due, in large part, to the introduction of Features, which have replaced the
more functional aspects, such as defining the structure of document libraries
and lists. We’ll be covering Features in more detail in Chapter 16, Features.
The important point here is that site definitions still exist and still play an
important role with respect to customization; therefore, if you want to cus-
tomize your deployment of SharePoint Server 2007 you need to have an
understanding of the underlying templating architecture. In this chapter, we
examine the templating aspects of SharePoint, such as site definitions and site
templates, and show you how to create your own custom site definitions and
templates. At the end of the chapter, we revisit the topic of branding and
walk you through another branding exercise that leverages site definitions.
15.1 Defining Site Definitions, Site Templates, and
Custom Templates
The terminology that Microsoft has used for their templating architecture
remains a source of confusion for many people. Perusing the various Microsoft
help files and MSDN and TechNet articles, you will find many inconsistencies,
especially regarding site definitions and site templates. The two terminologies
seem to be interchangeable in some texts and aspects of the product, highlight-
430 15.1 Defining Site Definitions, Site Templates, and Custom Templates
ing the fact that even the product team finds the whole topic confusing. Let’s
take a brief look at some examples of these inconsistencies.
The WSS 3.0 SDK describes a site definition using the following text:
“A site definition provides the base blueprint for a site, what lists it fea-
tures, the default navigation structure, etc. A site definition involves a set
of XML, ASPX, and other files on the front-end Web server.”
The same page in the SDK then goes on to describe a site template
using the following text:
“A site template is a package that contains a set of differences and changes
from a base site definition. This package is stored as an .stp file, which is a
CAB file that contains XML files that define the differences. The .stp file
can be downloaded and uploaded to site collections by users with appro-
priate rights, meaning that .stp files have some measure of portability.”
So a quick translation of the above is that a site definition stores the
server-based files used to instantiate a site. Once a site is instantiated from a
site definition, you can customize that site further by adding Web Parts, lists,
and so on, and then, using the browser interface, you can save your changes
to a site template file which you can use to instantiate additional sites.
So what’s wrong with these definitions? They seem perfectly fine on the
surface—it’s only when you actually start to work with the product that
things start to get confusing. The biggest offender is the fact that the folder
in which all site definitions reside is named SiteTemplates but it doesn’t con-
tain a single stp file! Also, when you start working with Features, you’ll find
that you can associate a Feature with a specific configuration defined within a
site definition, yet Microsoft refer to this association as the Feature/Site Tem-
plate Association and the actual element name used in the XML file is
Fea-
tureSiteTemplateAssociation
. Another example from the SDK is the
description of the
SiteProvision method. One of the parameters of this
method is
Name=”SiteTemplate”, and the description provided in the SDK
for this parameter is as follows:
“Specifies the site definition to use to instantiate the site. If not specified,
by default Windows SharePoint Services creates the site by using the stan-
Get Microsoft SharePoint 2007 Technologies now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.