Error message when you try to use an existing site template to create a new SharePoint Server 2007 site: "Failed to apply template"

Applies to: SharePoint Server 2010SharePoint Server 2013

Symptoms


Consider the following scenario:

You make changes to an existing SharePoint site and save the updated site as a template. Then, you try to use this template to create a new SharePoint site.

In this scenario, when you click Save Site as Template under Look and Feel on the Site Settings page, you receive the following error message:

Failed to apply template TemplateName.stp to web at URL
SharePointSiteName, error The template you have chosen is invalid or cannot be found.

Additionally, the template is not saved.

Cause


This issue occurs if the top-level site of the SharePoint site that you are trying to save as a template has publishing features turned on. In this case, Save Site as Template appears under Look and Feel on the Site Settings page.

Note: In order to prevent the use of the Save site as template feature for creating new sites, you must disable the Save site as template feature. However, if the top-level site has the publishing feature turned on, the option to turn off the Save Site as Template feature is disabled when you try to create a new site. This behavior also occurs in SharePoint Designer.

The supported method to create templates for publishing sites is to use site definition templates. For more information, visit the following Microsoft Web site:

Site Types: WebTemplates and Site Definitions

Workaround


To work around this issue, open the Feature.xml file of the Publishing feature in a text editor. This file is located under <Drive:>\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\TEMPLATE\FEATURES\Publishing folder on the SharePoint server

where

<Drive:> is the where SharePoint is installed

hange the Publishing feature directory to <Drive:>\Program Files\Common Files\Microsoft Shared\Web Server Extensions\12\TEMPLATE\FEATURES\Publishing for Office SharePoint Server 2007 and <Drive:>\Program Files\Common Files\Microsoft Shared\Web ServerExtensions\15\TEMPLATE\FEATURES\Publishing for SharePoint Server 2013

Manually add a new ElementManifest to the feature.xml. For example, add the following element
<ElementManifest Location="MyHideAction.xml"/>
Then, create a new MyHideAction.xml file in the same directory by using the following content
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<HideCustomAction Id="HideSaveAsTemplate" HideActionId="SaveAsTemplate"
GroupId="Customization" Location="Microsoft.SharePoint.SiteSettings" />
</Elements>

References


For more information about the Feature.xml file, visit the following Microsoft Web site:

Feature.xml Files