Working with Templates

There are methods for providing prepackaged site and list content in Microsoft Windows SharePoint Services:

  • You can build a new site definition. Site definitions include the set of basic pages and schema from which all SharePoint sites and lists are derived. Site definitions are stored on the file system of each front-end Web server as Web pages and XML files.
  • You can save an existing site or list as a custom template. Custom templates are a way of packaging up a set of changes to an existing site definition and making those available for new sites and lists. Every custom template is based on a site definition. Custom templates are stored in the database and made available through the central or site collection template galleries.

Each method can package up either an entire site or just one list. The site creation template picker page shows both site definitions and sites saved as custom site templates. The Create page shows lists defined in the site definition, and lists saved as custom list templates.

Working with Site Definitions

When you install Windows SharePoint Services on a Web server (Web server: A computer that hosts Web pages and responds to requests from browsers. Also known as an HTTP server, a Web server stores files whose URLs begin with http://.) computer, the default set of site definitions is also installed. Every site definition is stored in a folder on the file system of each front-end Web server and includes at minimum an Onet.xml file. Administrators of the server computer can create custom versions of the default set of site definitions. To create a custom version of a site definition, it is recommended that you create a new site definition, rather than editing the existing site definition files. If you edit the default site definition files, and then upgrade to a later version of Windows SharePoint Services, you will lose your customizations, and any sites based on the site definitions can potentially be broken. For more information about creating custom site definitions, see the Windows SharePoint Services Software Development Kit.

You can also mark a site definition as hidden, so it does not appear in the list of site types that users can create. For example, if you have a customized version of the Team Site template that you want users to base their sites on, rather than the default version, you can hide the default version of the Team Site template.

To mark a site definition as hidden, you modify the hidden parameter in the Webtemp.xml file. The Webtemp.xml file lists all of the site definitions available for the server, and is stored on the server computer at \Program Files\Common Files\Microsoft Shared\Web Server Extensions\60\Template\LCID\XML, where LCID is a locale ID (LCID) (locale ID (LCID): A 32-bit value defined by Microsoft Windows that identifies a particular language. The LCID consists of a language ID, a sort ID, and reserved bits. For example, the LCID for U.S. English is 1033, and the LCID for Japanese is 1041.), such as 1033 for U.S. English. You can open the Webtemp.xml file in any XML editor, such as Notepad. To hide a particular template, locate the section for that template in the Webtemp.xml file, and then set the hidden parameter to true. Set hidden to false to unhide the template.

For more information about working with site definitions, see the Windows SharePoint Services Software Development Kit.

Working with Custom Templates

You can create custom site or list templates for your users. To create a custom template, you save an existing site or list as a site or list template. You can add custom site templates to the central template gallery or the site collection template galleries, and you can add custom list templates to the site collection template gallery. When you save a site or list as a site or list template, it retains an ID that indicates which site definition the template is based on.

Template files include personal information such as server URLs and user account names. Only share template files with trusted users and groups.

About Site Templates

Users can customize a site and save the customized site as a site template, so that other users in the site collection (site collection: A set of Web sites on a virtual server that have the same owner and share administration settings. Each site collection contains a top-level Web site and can contain one or more subsites.) can create similar sites later. Site templates created by another user or software vendor can also be imported to the site collection template gallery.

To create a site template based on a Web site, you must a member of the Administrators site group for the current Web site. To add or import a site template to the site collection gallery, you must have the Add Items right for the site template gallery, which is included by default in the Web Designer and Administrator site groups for the top-level Web site in a site collection.

A site template is a file that includes all of the design information about the site, such as:

Site templates do not include the following items:

Site templates are stored as files with the .stp extension.

Using Site Templates

Users can create subsites based on templates available on the server or on the site collection. When a user creates a top-level Web site (top-level Web site: The default, top-level site provided by a Web server or virtual server. To gain access to the top-level Web site, you supply the URL of the server without specifying a page name or subsite.), he or she can base the site on a site template from either of the following sources:

  • The site definitions available on the server
  • Custom site templates in the central template gallery

When a user creates a new subsites (subsite: A complete Web site stored in a named subdirectory of the top-level Web site. Each subsite can have administration, authoring, and browsing permissions that are independent from the top-level Web site and other subsites.), he or she can choose from the combined list of templates from the following sources:

  • The site definitions available on the server
  • Custom site templates in the central template gallery
  • Custom site templates in the site collection template gallery

When the user creates a subsite, he or she chooses a template from templates available on the Template Selection page. This page shows all templates available on the server and site collection, filtered by the language that was selected on the Create Site page. The new subsite is based on the template, but can be customized and changed, just like any other site.

About List Templates

When a user creates a new list, he or she selects a list template to use in creating the list. Windows SharePoint Services includes many list templates by default, and users can customize an existing list and save the customized list as a new list template. List templates created by other users or software vendors can also be imported to the site collection template gallery.

You must have the Manage Lists right to create a list template. The Manage Lists right is included in the Web Designer and Administrator site groups by default. To add or import a list template to the site collection gallery, you must have the Add Item right for the list template gallery, which is included by default in the Web Designer and Administrator site groups for the top-level Web site in a site collection.

A list template is a file that includes all of the design information about the list, such as:

  • The columns and fields in the list.
  • Any views created for the list.
  • List content (optional).

List templates do not include:

  • Security settings, such as a list of users or groups with permissions to the list from which the template was created.
  • Lookup field links. Although lists can contain lookup fields that reference data in another list, that other list (and its data) is not included when you save a list template.

List templates are stored as files with the .stp extension.

Using List Templates

Users can create lists based on templates available on the server or on the site collection. To create a list based on a template, the user can go to the Create page in a site, and then click the list name to create. Custom list templates are listed on the Create page alongside the default set of list templates from the site definitions.

 Note   When a user creates a list, he or she can select a list template from the set of list templates on the server and the site collection. This set is filtered based on the site language and the site definition ID that your site is based on. For example, a site based on the Meeting Workspace template has a different site definition ID from a site based on the Team Site template. If you create a Meeting Announcements custom list template from the Announcements list in a site based on a Meeting Workspace template, that template is not available from within a site based on the Team Site template.

Creating Templates

Members of the Administrator site group (site group: A custom security group that applies to a specific Web site. Users are assigned to site groups to grant them rights on a SharePoint site.) for a site can create a template based on that site.

Create a site template
  1. On the site, click Site Settings.
  2. Under Administration, click Go to Site Administration.
  3. Under Management and Statistics, click Save site as template.
  4. In the File name box, type the filename to use for the site template file.
  5. In the Template title box, type the title you want to use for the template in the site template gallery.
  6. In the Template description box, type a description for the site template.
  7. If you want to include the existing site content, select the Include content check box.
  8. Click OK.

You must be a member of the Web Designer or Administrator site group to be able to create a list template.

Create a list template
  1. Navigate to the list you want to save as a template.
  2. Under Actions, click Modify settings and columns.
  3. On the Customize <List Name> page, under General Settings, click Save list as template.
  4. In the File name box, type the filename to use for the template file.
  5. In the Template title box, type the title you want to use for the template in the list template gallery.
  6. In the Template description box, type a description for the template.
  7. If you want to include the existing content, select the Include content check box.
  8. Click OK.

Managing the Site Template Gallery

Site templates are added or removed from the site template gallery at the site collection level. You must go to the Site Administration page for the top-level Web site in a site collection to manage the site template gallery.

When a user creates a site template, it is automatically added to the site template gallery for the site collection. If you want to import a site template from an .stp file, you can do so from the Manage Site Template Gallery page.

Add a template to the site template gallery
  1. On the top-level Web site, click Site Settings.
  2. Under Administration, click Go to Site Administration.
  3. Under Site Collection Galleries, click Manage site template gallery.
  4. On the Site Template Gallery page, click Upload Template.
  5. In the Name box, type the path to the template, or click Browse.

You can upload multiple templates by clicking Upload Multiple Files.

  1. Click Save and Close.
Delete a template in the site template gallery
  1. On the top-level Web site, click Site Settings.
  2. Under Administration, click Go to Site Administration.
  3. Under Site Collection Galleries, click Manage site template gallery.
  4. On the Site Template Gallery page, click the Edit icon next to the template name.
  5. On the Site Template Gallery: <Name> page, click Delete.

Managing the List Template Gallery

List templates are managed at the site collection level. You must be an administrator of the top-level Web site in a site collection to manage the list template gallery.

When a user creates a list template, it is automatically added to the list template gallery for the site collection. If you want to import a list template from an .stp file, you can do so from the Manage List Template Gallery page.

Add a template to the list template gallery
  1. On the top-level Web site, click Site Settings.
  2. Under Administration, click Go to Site Administration.
  3. Under Site Collection Galleries, click Manage list template gallery.
  4. On the List Template Gallery page, click Upload Template.
  5. In the Name box, type the path to the template, or click Browse.

You can upload multiple templates by clicking Upload Multiple Files.

  1. Click Save and Close.
Delete a template in the list template gallery
  1. On the top-level Web site, click Site Settings.
  2. Under Administration, click Go to Site Administration.
  3. Under Site Collection Galleries, click Manage list template gallery.
  4. On the List Template Gallery page, click the Edit icon next to the template name.
  5. On the List Template Gallery: <Name> page, click Delete.

Managing the Central Template Gallery

There is a centralized store of site templates called the central template gallery. This gallery is managed for your entire server or server farm (server farm: A centralized grouping of network servers maintained by an enterprise or, often, an Internet service provider (ISP). A server farm provides a network with load balancing, scalability, and fault tolerance.), and can only be managed by using the command-line tool, Stsadm.exe. You must be a member of the local administrators group for the server computer to manage the central template gallery.

You use the following operations to manage the central template gallery.

Operation Description
addtemplate Adds a template to the central template gallery.
deletetemplate Removes a template from the central template gallery.
enumtemplates Lists the templates currently in the central template gallery.

The addtemplate operation takes the required filename and title parameters and the optional description parameter. To add a template, you would use the following syntax:

stsadm.exe -o addtemplate -filename <filename> -title <template title> -description <description of the template>

The deletetemplate operation takes the required title parameter and the optional lcid parameter. To delete a template from the central template gallery, you would use the following syntax:

stsadm.exe -o deletetemplate -title <template title> -lcid <language>

 Note   After you add or delete a template from the central template gallery, you need to restart the Web service in Internet Information Services (IIS) (Internet Information Services (IIS): Software services from Microsoft that support Web site creation, configuration, and management, along with other Internet functions.). You can restart all of IIS at once by running iisreset on the command line, or just restart the specific Web sites in Internet Information Services (IIS) Manager. If you are in a server farm environment, you must restart the Web services for each front-end Web server in your server farm.

The enumtemplates operation takes the optional lcid parameter. To list all templates in the central template gallery, you would use the following syntax:

stsadm.exe -o enumtemplates

To list only templates for a specific language, you would use the following syntax:

stsadm.exe -o enumtemplates -lcid <language>

For more information about command-line parameters, see Command-Line Parameters. For a list of valid locale IDs (LCIDs), see Regional and Language Settings.

Using Site Templates from the Central Template Gallery

Users can create sites based on templates available in the central template gallery by using the same method as is used for any other site template. When the user creates a site, he or she chooses a template from templates available on the Template Selection page.

Administrators can also create sites based on the site templates available in the server template gallery. To create a site based on a template in the central template gallery, the administrator must use the createsite or createweb operation on the command line, and specify the template name as _GLOBAL_#number, where number refers to the template ID. For example, if you have a site template in the central template gallery with the ID 2, you could use the following syntax to create a site based on that template:

stsadm.exe -o createsite -url <url> -ownerlogin <DOMAIN\username>
-owneremail <someone@example.com> -sitetemplate _GLOBAL_#2

 Note   To find the template ID for a global template, you can use the enumtemplates operation.

Sharing Templates

You can share list and site templates with users outside of your site collection by giving them a copy of the .stp template file. You can give them a copy of the template file, just like any other file, by sending it in an e-mail message, posting it to a network share or Web site, or making a copy on a disk.

If the users are members of the Administrator or Web Designer site groups for their sites, they have the Add Item right for the site and list template galleries, and can add the site or list template to their site or list template gallery, and start using it.

To create a copy of a template, you must perform the following steps:

  1. Create the template.
  2. Navigate to the template gallery (whether site or list), right-click the file, and then click Save As to save the file to a network share or your local computer.
 
 
Applies to:
Deployment Center 2003