Search This Blog

Tuesday, December 23, 2014

What is the difference between Site Definition and Site Template?

Site Definition

Site Definition can be said to be the foundation for building a site in SharePoint, it contains 
all the artifacts that are needed for the site. A Site Definition can contain multiple site definition 
configuration. It is a collection of XML (using CAML) and ASPX pages. Each site definition consists 
of a combination of files that are placed in the %ProgramFiles%\Common 
Files\Microsoft Shared\web server extensions\14\TEMPLATE\SiteTemplatessub folders of SharePoint 
Foundation servers during installation of SharePoint Foundation. The XML markup in the site definition files
 may include references to files in other sub folders of %ProgramFiles%\
Common Files\Microsoft Shared\web server extensions\14\TEMPLATE, including .xml, .aspx, .ascx and 
.master page files, in addition to document template files (.dot, .html) and content files (.gif, .doc). 
The files related to the Site Definition are stored in the file system of the server and not in the content database.

Advantages of Site Definition
  • The Site Template is deployed to the file system and hence it is much faster
  • A high level of list customization is possible by making changes to the Schema.xml file
  • Certain kinds of customization to sites or lists require use of site definitions, such as introducing new file types, defining view styles, or modifying the Edit menu.
Disadvantages of Site Definition
  • The effort needed is much more than creating a site template
  • Once deployed making changes is difficult
  • Anything other than adding code can break the site definition
  • One cannot make use of the SharePoint Theme
  • Users cannot create two lists of the same time having different content
  • The user needs to have permission to access the file system
The site definitions that can be used to create a new custom site definition are as follows:
  • STS - includes definition for Blank Site, Team Site and Document Workspace
  • MPS - includes definition for Blank Meeting Workspace, Basic Meeting Workspace, Decision Meeting Workspace, Social Meeting Workspace and Multipage Meeting Workspace
  • BLOG - includes definition for Blogs
  • SGS - includes definition for Group Work Site
There are other site definitions but they cannot be used to create a custom site definition, which are as follows:
  • CentralAdmin - this provides the site definition for the central admin site
  • TenantAdmin - this provides the site definition for the site hosting features
  • Wiki - this provides the site definition for the legacy wiki sites
  • Global - this is used to initialize all the other site definitions
The two most important XML files that govern the configuration and structure are as follows:
  • WebTemp*.xml
    Identifies the site definition and configuration and how the UI will look.
    The built-in WebTemp.xml file and any supplemental WebTemp*.xml files that may have been deployed, specify which site definition configurations are available for creating sites. If you are creating a custom site definition and do not edit the original WebTemp.xml file, instead create a custom WebTemp*.xml file then SharePoint Foundation merges the contents of all WebTemp*.xml files when showing available site definition configurations in the UI. This simplifies installing and uninstalling site definitions, because their contents do not have to be merged into one WebTemp.xml file.

    Location: %ProgramFiles%\Common Files\Microsoft Shared\web server extensions\14\TEMPLATE\1033\XML
  • Onet.xml
    Onet.xml defines the top navigation and Quick Launch areas, specifies a basic set of list types that are available for creation, specifies document templates and their file types and itemizes the files and "all user" Web Parts that are available for use in site configurations. The global Onet.xml file, from which all other Onet.xml files inherit, defines the base types for lists, which include Generic List, Document Library, Discussion Forum, Vote or Survey, and Issues List. In addition, Onet.xml uses Configuration elements to define the site definition configurations in a site definition (such as STS and BLOG) and Module elements to define the modules in each site definition configuration.

    Location: %ProgramFiles%\Common Files\Microsoft Shared\web server extensions\14\TEMPLATE\SiteDefinitions\site_type\XML


Site Template
On the other hand Site Template is a package which contains all the changes made to the site from the base site definition used to create the site. They are stored in a file with the extension of .stp which can be created from within the site. The Site Template package are stored in a CAB based file which can be uploaded or downloaded from a site.

Advantages of Site Template
  • Site Template is easy to create
  • Almost every changes made to the site can be preserved in the template
  • Site Templates can be modified without affecting the other sites created using the template
  • It is easy to deploy
Disadvantages of Site Template
  • It is not created in a development environment
  • If the Site Definition on which the Site Template has been created does not exist in the server the site template will fail
  • It is less efficient in large environments


1 comment: