A. Overview When you create a SharePoint site, tailor its components and layout to your need and would like the Site Administrators to reuse your piece of work, then you somehow need to save it as a template.
I was recently working on a project which involved creating and working with custom site templates in Microsoft Office SharePoint Server 2007 (MOSS). I have encountered some problems and have done investigations in various topics which I would like to blog about.
This article is divided into two parts. The first one covers the actions you need to perform when working with Site Templates. The
second part is dedicated to troubleshooting errors while working with Site Templates.
B. Site Template vs Site definition The reason I have become acquainted with site templates is that I developed a team site that contains some custom lists, workflows and list views. I have also edited the web parts on the site’s home page. After I have finished this site, I was concerned about how I can save my work, in order to be reused on other sites without repeating all these steps.
While googling about that topic, I was confronted by two terminologies:
Site Template and
Site Definition. At first both seemed the same to me or at least both seemed to be able to fix my problem. But there must be a difference. Further googling has guided me to several comparison articles.
Summing up the differences…
- Site Templates are easier to create than Site Definitions. All the customizations can be done through the user interface or SharePoint Designer. Creating a site definition requires hand-coding a lot of XML files and other supporting files.
- Site templates are also easy to modify. But there is no easy way to modify site definitions once they are deployed. You can only add to the site definition once it is deployed.
- Site templates are stored in the configuration database. Templates in the database are compiled and executed every time a page is rendered; therefore site templates can result in slower performance. Site definitions typically perform better when cached on the file system instead of in the database.
- Because site templates are stored in the configuration database, the deployment of site templates does not involve server administrators. As for site definitions that require access to the file system, server administrators must always be involved in the deployment of site definitions.
For more details about the differences between site templates and site definitions as well as guidelines about when to choose one over the other, I recommend you to read
this article by Dino Dato-on and Jinger Zhao.
C. Save a site template - Open the Site Settings page
- Go to the Look and Feel section
- Click Save site as template
- Type a file name using a .stp extension
- Type a name and description for template
- Select the Include content checkbox, in case you want to new web sites created from this template to contain the content of all lists and document libraries in this Web site.
NOTE: If you have developed custom workflows and attached them to certain lists on the site, then you
must select the
Include content checkbox. This is because the custom workflows are considered as site content.
But what if you want to include the custom workflows in the site content but do not want to include the documents and items contained in the different lists? Here is a very simple trick to achieve your target:
- Perform the described steps for saving a site template
- Type stage_temp as the template name
- In step 6, you should select the Include content checkbox
- Create a new temporary site using stage_temp
- Delete all the documents and list items, you do not want to include in your site template
- Now repeat the steps for saving this temporary site
- Again, select the Include content checkbox. This is for saving the custom workflows
- For the sake of cleanup, delete the temporary site as well as the stage_temp site template
D. Download a site template - Go to the root site in the site collection
- Open the Site Settings page
- Go to the Galleries section
- Click Site templates
- In the Site Template Gallery, click the name of the template you would like to download
- Save the template to the desired destination.
E. Add a site template There are two ways to add a site template to the template gallery.
Method 1: Using the stsadm tool - Open the command prompt and browse the following directory: Program Files\Common Files\Microsoft Shared\web server extensions\12\BIN
- Run the command: stsadm -o addtemplate -filename template_file-name -title template_title [-description template_description]
- Reset Internet Information Services (IIS) by typing iisreset at the command prompt.
Click here for more details about the addtemplate operation.
Method 2: Uploading the file directly to the Site Template Gallery - Go to the root site in the site collection
- Open the Site Settings page
- Go to the Galleries section
- Click Site templates
- In the Site Template Gallery, click the Upload menu and then click Upload document
- Browse the template you would like to add and open it.
F. Availability of a template to individual sites Administrators usually need to manage the availability of a template in the gallery to individual sites. In other words, they set which site templates are available for creating subsites and pages. For instance, an administrator can define that
site X can use
template 1 but
site Y can use only
template 2.
To perform this task, follow the steps:
- Open the Site Settings page
- Go to the Look and Feel section
- Click Page Layouts and Site Templates
- Select Subsites can only use the following site templates
- Select the templates you wish to make available
- Click OK
NOTES: - You can choose to set the site templates from any site within the site collection not only from the root site.
- In a site where the Office SharePoint Server Publishing Feature is not enabled, the Page Layouts and Site Templates link is not visible under the Site Settings page. In this case, there is a turnaround for reaching the required page by browsing the following URL directly: http://{siteurl}/_Layouts/AreaTemplateSettings.aspx
G. Use a site template - From the Site Actions drop-down menu, choose Create
- Under Web Pages, click Sites And Workspaces
- Fill the Title, Description and Web Site Address fields
- In the Select a template section, click the Custom tab
- You should find your custom site templates under this tab
- Select a template
- Specify the permissions and navigation options
- Click Create
H. Rename the custom tab When adding custom site templates to your site, these templates land under a so-called
Custom tab in the Site Templates List on the Site Creation page. If you would like to change the name of the Custom tab, here are the steps that you should follow:
- Open the file Program Files\Common Files\Microsoft Shared\web server extensions\12\Resources\core.en-US.resx
- Search for TemplatePickerControl_Custom
- Change the content of the value element from Custom to to the new title you would like to display
- Reset Internet Information Services (IIS) by typing iisreset at the command prompt.
I. Delete a site template There are two ways to delete a site template from the template gallery.
Method 1: Using the stsadm tool - Open the command prompt and browse the following directory: Program Files\Common Files\Microsoft Shared\web server extensions\12\BIN
- List the site templates that have been submitted to the global site template catalog by running the command: stsadm –o enumtemplates [-lcid template_language_locale_ID]. Note that: Enumtemplates only displays the templates that you have installed from the command line for the farm, not the ones stored in a site collection gallery
- Run the command: stsadm -o deletetemplate -title template_title [-lcid template_language_locale_ID]
- Reset Internet Information Services (IIS) by typing iisreset at the command prompt.
Click here for more details about the enumtemplates operation.
Click here for more details about the deletetemplate operation.
Method 2: Delete the file directly from the Site Template Gallery - Go to the root site in the site collection
- Open the Site Settings page
- Go to the Galleries section
- Click Site templates
- In the Site Template Gallery, open the Edit page for the template you would like to delete
- Click Delete Item and confirm the deletion.
References Customizing SharePoint Sites and Portals: Using Templates and Site Definitions, Part 2
http://msdn.microsoft.com/en-us/library/ms916803.aspx All you ever wanted to know about SharePoint 2007 Site Templates
http://blah.winsmarts.com/2007-7-All_you_ever_wanted_to_know_about_SharePoint_2007_Site_Templates.aspx SharePoint Server 2007 Templates - it's all in the lingo
http://www.mindsharpblogs.com/kathy/archive/2007/04/10/1685.aspx Addtemplate: Stsadm operation (Office SharePoint Server)
http://technet.microsoft.com/en-us/library/cc261822.aspx Enumtemplates: Stsadm operation (Office SharePoint Server)
http://technet.microsoft.com/en-us/library/cc263342.aspx Deletetemplate: Stsadm operation (Office SharePoint Server)
http://technet.microsoft.com/en-us/library/cc263068.aspx Set Available Site Templates
http://stsadm.blogspot.com/2007/08/set-available-site-templates.html Rename Template "Custom" tab in SharePoint 2007
http://dirkvandenberghe.com/archive/2008/02/18/rename-template-quot-custom-quot-tab-in-sharepoint-2007.aspx Restarting IIS (IIS 6.0)
http://www.microsoft.com/technet/prodtechnol/WindowsServer2003/Library/IIS/003ed2fe-6339-4919-b577-6aa965994a9b.mspx?mfr=true