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 always struggle to find out that how to know what site definition or site template a "Web" or a "Site" is using. We do have a lot of custom site definitions and site templates, we are using in our portal, so If there is any freeware tool or way to find out, would be great.

We keep records of Site Templates in Database, but I want to know if there is any way, I find it out using a C# script or simply any app.


share|improve this question
up vote 2 down vote accepted

Run the following code in your C# Console Application and you'll get the listing all your sub-sites with their respective site definitions

using (SPSite ospSite = new SPSite("http://server/"))
    SPWebCollection webs = ospSite.AllWebs;
    foreach (SPWeb web in webs)

          string template = web.WebTemplate;
          Console.WriteLine(web.Url.ToString() + " : " template.ToString());
       finally {web.Dispose();}

share|improve this answer
Cheers brother done it, I was wondering if you have any twitter account or LinkedIn , i can follow you :) – Muhammad Raja Jun 26 '12 at 8:31
As I say it, follow me at your own risk ;)!/falaky – Falak Mahmood Jun 26 '12 at 8:34

Use SPWeb.WebTemplate property.

share|improve this answer

Your Answer


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

Not the answer you're looking for? Browse other questions tagged or ask your own question.