Web Templates – What base template should I use?

I have had some interesting discussions with Wayne Ewington and others on what base template should you use for web templates.

A little background to what this base template means to web templates:

Web Templates depend on an existing site definition installed in the server. The general guideline is to always reference a site template that is always going to be present.

Let us take a look at the web templates Elements.xml file:

 <?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="https://schemas.microsoft.com/sharepoint/">
  <WebTemplate
    Name="TechEdWebTemplate"
    Title="TechEd Web Template"
    BaseTemplateID="INSERT BASE TEMPLATE ID"
    BaseConfigurationID="0"
    BaseTemplateName="INSERT BASE TEMPLATE NAME"
    DisplayCategory="TechEd"
    Description="TechEd Web Template"
    Subweb="FALSE"/>
</Elements>

The highlighted attributes are what we are interested in.

So what do we use?

It is always better to use the most popular Team Site site definition. The reason is, this is the site template you can always expect installed in the server – whether you are using SharePoint Foundation or SharePoint Server 2010 Standard or SharePoint Server 2010 Enterprise.

The other thing to note is that web templates only work with Configuration ID 0. This is a key thing and again choosing Team Site site definition is better as we are always going to have a Configuration ID 0 associated with the site definition.

Our Elements.xml will now be:

 <?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="https://schemas.microsoft.com/sharepoint/">
  <WebTemplate
    Name="TechEdWebTemplate"
    Title="TechEd Web Template"
    BaseTemplateID="1"
    BaseConfigurationID="0"
    BaseTemplateName="STS"
    DisplayCategory="TechEd"
    Description="TechEd Web Template"
    Subweb="TRUE"/>
</Elements>

What about onet.xml ?

The beauty of web templates is you can customise the onet.xml to include the required features for your site. That means, you can use the team site definition, and still activate publishing features in your onet.xml. It doesn’t matter.

I strongly recommend reading Vesa’s post on web templates to understand how web templates work in SharePoint 2010.

My TechEd 2011 session sample is also updated to reference the team site definition.