What are site templates?
Sometimes, you need to create the cutter for sites, so you can create cookie cutter sites easily. SharePoint comes with a few such cookie cutters out of the box. You might have seen this cookie cutter picker when creating a site/site collection etc. as shown below:
Those are usually site definitions (not Site Templates). I have covered the process of registering custom site definitions over here.
The obvious Q here is, How are Site Templates different from Site Definitions?
Site Templates vs. Site Definitions
- Site Templates are a LOT easier to create than Site Definitions. You can create a site template using point and click. Creating a site definition requires hand-coding a lot of XML files and other supporting files.
- Site templates serve a customized version of pages, i.e. low performance. Site definitions serve uncustomized pages, i.e. high performance. Thus you should choose site definitions over site templates, if a large number of sites will be created based on this cookie cutter.
- It is fairly easy to move around a site template. It is a tad bit (but not horribly more) complex to move around site definitions.
How to export a site to a site template?
Pretty darned easy. Go to http://<yoursiteaddress>/_layouts/savetmpl.aspx . Note: There is no UI point and click that takes you to this URL for a site, so note this URL down.
You are presented with the following form.
Fill it out, and hit "OK". The template file (.stp) gets saved under the Site Template Gallery, which can be accessed by going to the Site Collection, Site Actions --> Site Settings --> Modify All Site Settings, and clicking on the "Site Templates" link under the "Galleries" section. As you can see, the entire site got squeezed into a single .stp file (which is really a cab file). Quite impressive. :-)
How to register a site template inside a site?
How to restrict certain sites to use only certain site templates?
Okay, so now you have created a cookie cutter for your site. The next obvious question is, "How can I use this cookie cutter?".
a) You need to make sure that the site template exists on the site collection. This can be done by uploading an existing site template to the site template gallery. As mentioned above, the site template gallery can be found by going to the top level site in the site collection, then going to Site Actions --> Site Settings --> Modify All Site Settings, and clicking on the "Site Templates" link under the "Galleries" section. Alternatively, you may also use the stsadm -o addtemplate command.
b) The next step is that you need to make this template uploaded in the gallery available to individual sites. So that is basically saying that Site A can use template X, but Site http://A/B can use only template Y. You would note for instance that out of the box, a publishing site lets you choose only "Publishing site with workflow" definition based sites as child sies. Well you can change that.
1. Just go to http://<yoursiteurl>/_Layouts/AreaTemplateSettings.aspx NOTE: Note down this URL :-), there is no point and click way of getting to at the site level. At a site collection level, you may use Site Settings -> Modify all Site Settings -> Page Layouts and Site Templates to reach the same page.
2. Pick the templates you'd rather have available as shown below:
.. and hit "OK". Now the appropriate site templates will show up in the cookie-cutter-picker. :-) w00t!
Ummm .. thats about it as far as site templates go. Anything I missed re: Site Templates? Leave a comment or send me a message.