Applying Site Templates Programmatically in SharePoint 2010
In previous versions of SharePoint, applying a site template (STP) to a new site through the object model was just a matter of referencing the template by its filename.

In SharePoint 2010, site templates are stored and referenced a little bit differently. When saving a site as a template, the site is packaged as a WSP and stored in the site collection solution gallery. The contents of the template are different from STP’s which is why they are not compatible and you must re-save all your templates when migrating to SharePoint 2010.
Attempting to apply a template by name no longer works and you will receive an error saying the template cannot be found. The reason being that template names are now stored with a GUID that is unique to the site collection where the template resides. NOTE: The GUID is not the same as the Solution Id that you see above. The easiest way I’ve found so far to determine the template name is to use a PowerShell script.
Script:
Add-pssnapin Microsoft.Sharepoint.PowerShell
$site = get-spsite “http://server.url” //Replace with your URL
$site.GetWebTemplates(1033) | format-table name
After running the script, you should get output that looks like the following.

This is the template name that you must use when applying the template to a new site.

One thing that I’m still looking into is deploying site template solutions globally. In 2007 it was a simple command:
· stsadm –o addtemplate –filename ProjectTemplate.stp –title “Project Template”
However, in 2010 this command no longer works and I have yet to find some type of global solution gallery in which to deploy. Adding the solution via stsadm –o addsolution does not seem to work either. I will update this post if I find another way.