SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I've copied the same question I found in an answer in this link because it is happening to me: when I create a new site using powershell or code, it is using an old version of the template. Not happenning throught Sharepoint Wizard.

Programmatically create Site using Custom Web Template in Sharepoint 2010

(...) For example, I have the site template called "hosts" first, then I removed it, recreate a new site template called it with the title "hosts" again. So my problem is, when the new site was created, it was using the old "hosts" template instead of the new one, any one can help me?

string templateFromMethod = GetTemplate("hosts", siteInUserContext);

SPWeb newSubWeb = subsites.Add(TextBox1.Text, TextBox1.Text, TextBox1.Text, 1033, templateFromMethod, false, false);

private static String GetTemplate(string solutionName, SPSite siteCollection)
            string templateName = null; 
            //SPWebTemplateCollection coll = siteCollection.GetWebTemplates(1033); 
            SPWebTemplateCollection coll = siteCollection.GetCustomWebTemplates(1033); 
            foreach (SPWebTemplate template in coll) 

            if(template.Title.Equals(solutionName, StringComparison.CurrentCultureIgnoreCase))
                    templateName = template.Name;
            return templateName; 
share|improve this question

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.