Site Types: WebTemplates and Site Definitions
Applies to: SharePoint Foundation 2010
In Microsoft SharePoint Foundation, when users create a site through the user interface (UI), they do so by selecting one of two possible types of foundations that can define how to instantiate the site:
A site definition configuration (which is a part of a site definition)
A custom web template
Either type of foundation determines, for example, the lists, files, Web Parts, Features, or settings with which to provision a new SharePoint Foundation site.
Site definitions consist primarily of multiple XML and ASPX files stored on a front-end web server in folders under the %ProgramFiles%\Common Files\Microsoft Shared\web server extensions\14\TEMPLATE\SiteTemplates directory.
Custom web templates are stored in the database—specifically, the sandbox solutions gallery—and are created by using an existing site, with or without its specific content, as a model. This provides a means for reusing sites that you have customized.
Because custom web templates are based on existing sites, at least the first site in any SharePoint Foundation deployment must be founded on a particular configuration within a site definition.
In some ways, web templates continue to depend, throughout their life cycle, on the site definition that is their ultimate foundation. For this reason, we do not support changing or removing a site definition after sites have been created from it. Such changes may cause sites that are created from the definition (or created from web templates that are based on the site definition) to stop working correctly, or they may prevent the creation of new sites that are based directly, or indirectly, on the site definition. For more information about what kinds of customizations of site definitions are supported by Microsoft, see Supported and unsupported scenarios for working with custom site definitions and custom area definitions in SharePoint 2003, 2007 and 2010.
In the SharePoint Foundation object model, an SPCustomWebTemplate can represent either a site definition (and configuration) or a custom web template.
In Collaborative Application Markup Language (CAML) markup, a site definition is represented by the combination of two things:
A Template element in a WebTemp*.xml file in the installation directory, usually %ProgramFiles%\Common Files\Microsoft Shared\web server extensions\14\TEMPLATE\LCID\XML\, where LCID is the numeric ID of the language/culture, such as 1033 for English.
An Onet.xml file in the installation directory, usually %ProgramFiles%\Common Files\Microsoft Shared\web server extensions\14\TEMPLATE\SiteTemplates\site_type\XML\, where site_type is the name of the site definition. So site_type can be "STS," "MPS," "BLOG," "SGS," or the name of a custom type of site.
But such a site definition is really a family of one or more site definition configurations, each of which is represented by one of the Template element's child Configuration elements. Details of the configuration are stored in a corresponding Configuration element in the Onet.xml file.
By contrast, a custom web template is stored as a .wsp file in the SharePoint Foundation database and is listed in the Sandbox Solutions gallery for the site collection. You can copy the file to a folder, change its extension to ".cab", and open it. The .wsp file includes an elements.xml file, and in that file is a WebTemplate element. There is also an Onet.xml file in the .wsp package, although it is simpler than the Onet.xml that is typically found in a site definition.
The topics in this section describe how you can create custom web templates (the preferred approach) and custom site definitions (which in some scenarios you must do).