// Add template to the global gallery so you could use any where
stsadm -o addtemplate -filename Regions.stp -title Regions
// You could check the template availability
stsadm -o enumtemplates
Of case there are several major issues associated such as feature compatibility across environment and workflow will not working if save template with content. Of cause we have identified workarounds already last year to resolve those issues. I’m not a fun of site template and prefer to use site definition sue to the better maintainability.
SharePoint 2010 is little different and there are many ways to implement reusable templates. To be specific using site template inn 2010, you can choose to load a site template to create sub sites or site collection at creation time. Here are two major use cases.
1. The most user cases are using saved template as sandbox solution gallery in the solution to create sub site. The default wsp file saved is web scope and sandbox solution anyway. You could refer this blog on the procedure. It’s quite simple and I will not explain this in the blog.
2. The second use case is users wants this template available to create site collection from site collection. In additional this template should be available globally to be provisioned by auto-provisioning tool such as SharePoint Site Provisioning and Governance Assistant (SPGA) tool we are using to automate the site creation and approval process. In order to make it available in central admin when creating the site, there are some options and I’m listing the best option from our implementation to our end users. Again, as I mentioned before, I’m still prefer to use site definition unless we have to use site template sine it save some time.
There are several options to do this and some of them does not make sense to me and I was totally lost at beginning. You should avoid those if you need to use site template.
The first way to install template seems like to use powershell command Install-SPWebTemplate. Here are the procedure and issues.
Command: Install-SPWebTemplate -path "E:/Harry/Temp1.wsp" -name "Temp1" -description "TestWSP" -Confirm:$false
Error is : Cannot find or parse web template file E:/Harry/Temp1.wsp
Result: You will not get template installed and I’m not sure what the usage of this powershell usage and could not figure out
The second way is to deploy the solution using powershell command Add-SPSolution. Here are the procedure and issues.
Commands: Add-SPSolution -LiteralPath " E:/Harry/Temp1.wsp"
Install-SPSolution Temp1.wsp –GACDeployment
Issue is : Cannot find it from central admin to use for site collection creation
Workaround: You have to do some configuration to use it. See the blog for details.
The third way and I believe the best way inspired by the response from Mirjam’s response is to repackage the wsp using Visual Studio and deploy as farm solution. Here is the way to do this and you have much better control and maintainability. Here are the steps we implemented it.
- Create a new SharePoint 2010 project using Visual studio
- Selecting “Import SharePoint Solution Package” template
- Browse site template WSP file you want to use and select “Deploy this WSP as farm solution” – This is critical to make it available in the farm
- Select items you need as site template existed on this WSP to be packaged and click ok
- Change the web template feature scope from site to farm so that we can see this template on site collection creation page. Be aware of multiple features and you need to select the right one feature
- Add DisplayCategory="MyTemplate" on web template elements.xml file to include this template on your MyTemplate tab
- Package this solution and deploy the using Add-SPSolution
- Now open the Site collection create page, we can able to see “Temp1” template on MyTemplate tab as shown in below screen shot.
At this time, you should be able to use this site template to create new site collections or sub sites. However, there is potential issue that may prevent sites to be created successful - feature comparability. Unless you have exact same features installed on the farm as the site you saved as site template, you have have error feature not installed on the farm error when creating sites. I'll address this issue in later blog.
There is another issue on the sites created from such site template - the sites could NOT be backed up using Site Recycle Bin tool (Previous Site Deletion Capture) on SharePoint 2010 just discovered. I have described in the another blog http://sharepointconnoisseur.blogspot.com/2011/04/tips-and-tricks-for-site-recycle-bin.html.
Hi,
ReplyDeleteI would like to exchange some in-depth consideration on this post. I'm having the same damn problem and I'm not coming out of it. Can we please exchange email? Mine is paolo.sardi@consulenti.assioma.net
Best regards.
excellent , this helped me :)
ReplyDelete