Have you ever looked at an existing SharePoint site and wondered which site template was used to create it? While cruising the Internet, I have come across several blog entries that offer code to retrieve the site template associated with an existing SharePoint site and while the code is useful, the snippets I've seen require modification by someone experienced with C#.NET or VB.NET. Furthermore, the snippets offer no translation of the cryptic template names that show up in their results (there are other blogs offering different code for that). Nothing against these code bloggers, I have the utmost respect for developers, but it occurs to me that site template information can also be retrieved without writing code by running STSADM.EXE or by directly querying the WSS_Content database in SQL Server.
STSADM
Beware that the following operation requires Site Collection Administrator or higher authority and is only available after installing SharePoint's Service Pack 2. Conversely, the default NTFS ACL on the SharePoint 12 hive files noted in the subsequent paragraphs contain an ACE for the Authenticated Users Windows system group that grants Read and Read+Execute...so rest assured you'll be able to read the files.
A quick stsadm.exe -o enumallwebs -database {content database name} operation at a Command Prompt reveals the TemplateName associated with each site in the subject database, such as "STS#0" for those sites created using the "Team Site" system-supplied site template. To translate "STS#0" into the more widely recognized "Team Site" name of the template, open the webtemp.xml file in the 12 hive path: C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\1033\XML (assuming US English templates for locale 1033). This file contains details about the system-supplied site templates that ship with the Team Collaboration Feature. Using Notepad to read webtemp.xml (below), notice that the <Template> element with the Name="STS" bears a configuration option with the ID Number of "0". Translation: "STS#0". The user friendly Title of this configuration option is the easily recognized "Team Site" string. Sweet!
NOTE: There are actually multiple webtemp*.xml files in the 12 hive that contain information about the various system-supplied site templates depending on which Features are installed in SharePoint. A list of the defaults appears at the end of this post.
SQL SERVER
DBA's who do not have the necessary authority to execute stsadm.exe or are in pre-SP2 environments can still determine what site template was used to create a site by directly querying SQL Server (assuming the DBA knows which SharePoint content database houses the site in question).
DISCLAIMER: Microsoft Best Practices caution against direct contact with the SharePoint databases in SQL Server. The following SQL example is not supported by Microsoft but is a common enough question I've been asked by SQL Admins that I thought I'd shed some light on it.
The dbo.Webs table of any given content database contains a bevy of details about the sites housed by the database. Details such as: Site GUID's, Titles, URL's, and more along with each site's associated site template in the WebTemplate column and more specifically the configuration option of said template in the ProvisionConfig column.
Sample dbo.Webs table opened in SSMS
For example, say you want to find out which site template had been used to create a site entitled Consulting Team Site (I know, the site title kind of gives it away...but work with me here). The following simple SELECT Transact-SQL query to the WSS_Content database:
SELECT Title, WebTemplate, ProvisionConfig
FROM dbo.Webs
WHERE Title='Consulting Team Site'
would return the ID number of the site template and configuration option associated with the Consulting Team Site web site. Let's assume this example returned the value "1" for the site template ID number from the WebTemplate column and a value of "0" for the configuration option ID number from the ProvisionConfig column. Great! From the webtemp.xml file displayed in Notepad earlier it's easy to find the <Template> element with an ID number of "1" (it's the template with the Name="STS"). And within that template, the configuration option ID Number of "0" corresponds to the friendly-titled "Team Site" site template. Mission accomplished!
PS: Here are the default MOSS webtemp*.xml files from the 12 hive that contain available system-supplied site template information within:
File Name | Site Template Information For... |
webtemp.xml | STS (Team Site, Blank Site, Document Workspace) ; MPS (Basic Meeting Workspace, Blank Meeting Workspace, Decision Meeting Workspace, Social Meeting Workspace, MultiPage Meeting Workspace) ; Wiki Site ; Blog |
webtempbdr.en-US.xml | Document Center |
webtempoffile.xml | Records Center |
webtempsps.xml | Personalization Site ; Publishing Site ; Publishing Site with Workflow ; News Site ; Site Directory ; Report Center ; Collaboration Portal ; Search Center with Tabs ; Publishing Portal ; My Site Host |
webtempsrch.xml | Search Center |