How To Find Custom Template ID Using Template Name In SharePoint

Sometimes, there are situations when we need to identify Template Id that we have created for custom template.

Suppose, I created Team Site. When I save that site as Template, it will be shown to me in “Custom Templates” field everytime I create a new site/subsite.

There are two ways to find out the TemplateId for custom template.

  • Using User Interface

  • Using Programming

Way 1 :  Using UI 

Step 1

Press F12 or Right click > Inspect Element.

Step 2

You will find its Custom TemplateId easily.

Way 2 : Using Programming

There are some situations when we have to find TemplateId programmatically using TemplateName.

In that situation, what should we do? 

Well, here is a solution. The following code will return WebTemplateId using its name.

Below is a description for parameters.

templateTitle = Name of a custom Template which we want to find out.


Suppose we want to find out Template ID for “Custom Template 2”. Then, pass the value for templateTitle = “Custom Template 2”.

function CreateSubsiteByTemplateName(templateTitle) {   var context = new SP.ClientContext.get_current();  

var web = context.get_web();      context.load(web);   var webTemplates = web.getAvailableWebTemplates(1033, false);      




var enumerator = webTemplates.getEnumerator();  

var templateId = "STS#0";  

while (enumerator.moveNext()) 


var webTemplate = enumerator.get_current();  

var webTitle = webTemplate.get_title();  

if (webTitle == templateTitle) {                  

templateId = webTemplate.get_name();  


}          }  

return templateId;      


function(sender, args) 





The above function will return TemplateId for custom template.

Please let me know if you have any questions.

Recent Posts

See All