Sdílet prostřednictvím


Web Templates

Applies to: SharePoint Foundation 2010

When a user who has design rights customizes a website in the user interface (UI) or in a web-editing application, such as Microsoft SharePoint Designer, and then saves the website as a template, a web template is created. Web templates are stored in the Solutions Gallery of the top-level site in a site collection, where they become available for subsite creation on all websites in the site collection.

A web template is persisted in the SharePoint database as a Microsoft SharePoint Foundation Solution, which is a file that has a .wsp extension. The .wsp file is stored in the Solutions Gallery of the site collection. The solution can also be deployed as a sandboxed solution.

Web templates can be downloaded, edited, and redeployed as a sandboxed solution to other site collections.

We recommend that you create a web template when your solution involves a custom site type. For more information, see Deciding Between Custom Web Templates and Custom Site Definitions.

Users create web templates on the Save as Template page (or through code that uses the SaveAsTemplate method of the Microsoft.SharePoint.SPWeb class). You will probably find it easiest to begin a web template project the same way, although you can create the constituent files of the .wsp package individually and package them by using Microsoft Visual Studio if you prefer. You can also create a web template in the UI, import it into Visual Studio, and modify it before repackaging it and redeploying it.

Note

A .wsp file is actually a .cab file. You can save a copy of the file from the Solutions Gallery, change the file name extension from .wsp to .cab, and open the file in Windows Explorer.

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. Making 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 it may prevent the creation of new sites that are based directly, or indirectly, on the site definition. For more information about the relation of web templates to site definitions, see Site Types: WebTemplates and Site Definitions. For more information about what kind of customizations of site definitions are supported, see Supported and unsupported scenarios for working with custom site definitions and custom area definitions in SharePoint 2003, 2007, and 2010.

See Also

Reference

SPSolutionExporter.ExportWeb

SPSolutionExporter.ExportWebToGallery

Concepts

Site Types: WebTemplates and Site Definitions