The Problem

Web templates allows you to specify which features to activate by customising the onet.xml file. Usually developers will pick the nearest one or more site definition’s onet.xml they want to use – copy the WebFeatures and SiteFeatures (which is totally acceptable). For example, for a publishing site I may use the CMSPUBLISHING onet.xml which you can find at:

C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\TEMPLATE\SiteTemplates\SPS\XML\onet.xml

But what about if your web application is subscribed to a content type hub and you are expecting those published content types to come down to your new site created using the web template?

If you check your site (provisioned using a web template) settings, you will not find the ‘Content Type Publishing’ setting under Site Collection Administration. This is the place where you will see the content types consumed by the site (from the content type hub).

Below is a screenshot of this setting:

The highlighted option will not be available if you used a web template.

What is missing?

SharePoint feature staples a hidden feature to enable this functionality on sites. As you may guessed already, this feature stapling works when you create a site from the default site templates available, but not when you create a site from a web template. As a matter of fact, web templates do not support feature stapling!

All we need to do now is include this hidden site feature in our web template’s onet.xml!

The Solution

This hidden feature is TaxonomyFeatureStapler which can be found at:

C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\TEMPLATE\FEATURES\TaxonomyFeatureStapler

Hang on, if you look at the feature elements file (TaxonomySitesToStaple.xml), it actually associates another feature. This feature is TaxonomyFieldAdded which can be found at:

C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\TEMPLATE\FEATURES\TaxonomyFieldAdded

So, this is the feature we are interested in. Now we can add this feature in the SiteFeatures element (as this is a site feature & farm scoped web template)

[ TaxonomyFieldAdded feature GUID: 73EF14B1-13A9-416b-A9B5-ECECA2B0604C ]

If the web template is site scoped, you may need to activate this feature from a web scoped feature as SiteFeatures element don’t get parsed o a site scoped web template.

Now your site provisioned by a web template will be able to consume the content types published from its content type hub.