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; 

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.