Differences between site definition and site templates


In this article I am describing the differences between site definition and site template. Many people have asked me in which situation should we go with site definition and in which should we go with site template. All these questions will be answered in this article.

Site Template

The first option for getting the SharePoint Designer changes beyond the current site is to take the site you have modified with SharePoint designer and save it as a template. You can download the template and upload this to another site collection and can create a site based on this template. Whenever you need a new site you can create it from the site template you have created. This is a good approach if the design is finalized and you want to reuse the same template in different site collections. But keep in mind you can't go back and apply the changes after the site is created. If you make any changes to the work that you did on the original site then those changes won't be reflected across the other SharePoint sites that were created from the same template. This is because each page exists separately in the SharePoint database. So site templates solve the problem of getting SharePoint Designer changes into multiple sites but without the ability to adapt to changes in the future. Once the design is done we have to go to each site then do the same changes we want.

Site Definitions

This approach solves the problem of site templates. Here changes can be affected to them after they have been created. Site definitions exist on the file system of each of the front end web server. But as I mentioned earlier site templates exist in the content database. Each site which is created from the site definition doesn't make a copy of the page in the content database; but it stores a pointer to the site definition file. When a page on the file system changes it changes all of the references in the database thus solving the problem of making changes to existing branding or other functionalities. Site Definitions are stored on the hard drive of the SharePoint front end servers. They are used by the SharePoint application to generate the sites. Site Templates are created by users as a copy of a site they have configured and modified so that they do not have to recreate lists, libraries, views and columns every time they need a new instance of a site.

In order to create a site definition, we should first have to get the changes to the files that we want into files. We can do this from SharePoint Designer by selecting Save As and pointing to a directory. Now you can  create the support files for the site definition including the ONET.XML file which tell how the site definition is used, and the WEBTEMP.XML file which makes the site definition show up as an option. Better you start with a copy of the STS site definition that comes with SharePoint and make your changes there rather than starting from scratch.

So in a nutshell

1.      To create or use a site definition you need server admin access, but site template can install from web UI by site owners.

2.      Site definition supports feature stapling, but for site template additional features must be activated in gallery.

3.       Site definitions are stored on hard disk, but site templates are stored in content DB.

4.       Site definition can provision multiple webs, but site templates are for single web only.

5.      Creating site definition is relatively more complex than site template creation.