Using the SharePoint 2010 WebTemplate Feature Element for creating Site Templates

In SharePoint 2007 it was possible to save a site as a site template with a .stp extension. Saving a site as a template can be done from the site settings user interface. The .stp file is, like most SharePoint specific file extensions, a .cab file. The .stp file contains a link to the original site definition that the saved site depended on and the delta between that site definition and the saved site.

In SharePoint 2010 we can still save sites as templates in much the same way. However, saving a site as a template won’t create a .stp file, but a .wsp SharePoint Solution file! The .wsp file doesn’t just contain the delta, but it contains the onet.xml of the original site definition and all features and elements and optionally also content. What’s new in SharePoint 2010 that makes this possible is the WebTemplate Feature Element. There isn’t a lot of documentation on the WebTemplate element yet. Basically all I could find was documentation related to Sandboxed Solutions, as you can use the WebTemplate Feature Element in Sandboxed Solutions. The most elaborate description can be found here:

In short the story is that you can use the WebTemplate element to create a site template instead of the WebTemp.xml file that you would use to create a site definition. You can create site templates by either saving an existing site as a template, or you can create a site template using Visual Studio. If you create a site template by saving a site you can import the resulting .wsp package into Visual Studio. Note that if you do this that a lot of elements, like content types, site columns and properties from the property bag get imported into Visual Studio. Fortunately you can easily adjust the contents of the imported site template. You can clean up the template, but you can also make additional adjustments to it. Another benefit of importing the site template into Visual Studio is that it’s easy to put it under source control.

webtemplate example

The image above shows an example of what the WebTemplate element could look like. The most important thing to note from the image is that the WebTemplate has to reference the Template and the Configuration of the site definition the template is based on.

The debate about whether to use a site template or a site definition that was a lively one in SharePoint 2007 will probably continue to exist in SharePoint 2010. However with the introduction of .wsp site templates and the WebTemplate element site templates are now a whole lot more flexible and robust. One definite advantages of using site templates is that a site template can be deployed as a sandboxed solution. This means that the .wsp file can be deployed to the solutions gallery at site collection level. Anyone with site collection administrator rights can do this, so no access to the server is required. Only users within a site collection where the site template is deployed to can create sites based on the site template.
It’s also possible to deploy the same .wsp package as a farm solution to the farm’s Central Administration site. In order to do this a farm administrator that has access to the SharePoint server needs to add and deploy the solution to the farm. In this scenario the feature with the site template in it can activated on all site collections. Once the feature has been activated on a site collection users within that site collection can create sites using the template.

In the near future a lot more information on the new WebTemplate feature element will probably be published, but this is at least a short primer on what the element is and how to use it.
Have fun!

Comments -
  1. Gravatar

    Very cool, thanks for writing this up Mirjam. Interesting stuff. Making Site Definitions on the file system was a lot of work that required a dev resource. Making that easier would be wonderful. And .WSP could help with portability across farms and in multi-tenant setups.

  2. Gravatar

    I was doing this just today and was somewhat overwhelmed with all the files it generated. I think I'll be sticking to the programmatic approach with Feature Stapling on top of a base template to just do the differences. It'll be easier to maintain and will be more apparent what the additions are ;-)

  3. Gravatar

    Hey Mirjam,

    I think WebTemplate element features are a great addition in SharePoint 2010 and are the new gold standard for custom site deployments.

    I put up a post with some details and sample code on creating a WebTemplate solution in VS2010 from scratch. I am now using this as the base for most of my custom application development projects.

  4. Gravatar


  5. Gravatar

    Thanks for this article. I have a question here.

    How can I programmatically create a site collection in SharePoint 2010 based on a site template (which is saved as .WSP} ? Earlier in 2007, we could to it with .STP.

    Would appretiate your response.


  6. Gravatar

    Hi Anwar,

    From my site Definitions vs Web Templates post (

    You can also create a site based on a web template by using custom code. You simply use [Feature Guid]#[Web Template Name]. Spaces in the web template name are no problem.


  7. Gravatar


    does Feature Stappling is Supported in Custom Web Template Feature Element for creating Site Templates ?

    Thanks in Advance.

  8. Gravatar


    Unfortunately it's not possible to use Feature Stapling with Web Templates in SharePoint 2010.
    Also check out this post:


  9. Gravatar

    One of the really exciting new options on the Feature Framework level of the SharePoint 2010 is the WebTemplate

  10. Gravatar

    Thanks Mirjam.


  11. Gravatar

    Power to the people. Web Templates (I sometimes like to call them "sandbox templates" just for fun) are great way to put power users in control of their site collections. Sorry developers, but it ain't all about us :-)

    Don't get me wrong, I've written a handful of really useful custom base definitions for publishing sites, but custom definitions really complicate your upgrade route. And with team sites the temptation is to make dozens of definitions to address every collaborative variation - but why not let Site Collection Admins manage their own variations? So if HR wants an extra page on their meeting sites but Sales doesn't, let them manage that themselves with a 'sandbox' template. Yes, I am both lazy and liberal...

    Jeremy, I get your point about staying in control of additions but isn't feature stapling against base site definitions a blunt tool? Unless maybe you really do want to make the same changes to all sites based on a definition (regardless of department or the preferences of the Site Collection Admins). Sure there are corporate policies that might demand that sort of thing. But for most occasions, why not just throw the feature out there and let SPweb or SPSite owners activate it if and when they want to?

    If we put some logic in the feature so that it only makes changes to webs where the base definition is, say STS#0, then we can still cascade down changes into sub-sites associated with that definition. The difference is that Site Collection Admins can decide whether or not to make those changes, rather than having to live with a farm-wide decision. It's all about managing your own tenancy. Though this approach would also require an event handler on newly created sites to deal with sites created after the feature is activated (same main feature though so not complex for a humble power user).

    Cheers, Darren.

  12. Gravatar


    I'm looking for a publishing site definition and also i need to staple few features. Thats teh reason why i'm goin with site definitions rather goin with site templates.

    Can you please give me the list of features we need toactivate for publishing site definition.

  13. Gravatar

    Hi Ramesh,

    If you mean by a "publishing site definition" a site definition that has the publishing features activated on it, you will need to activate the Publishing Infrastructure site collection feature and the Publishing site feature on it.

    However the easiest thing you can do is to take ONET.xml of the out of the box Publishing Site. You can find the ONET.xml for this type of site in the C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\TEMPLATE\SiteTemplates\PUBLISHING\XML folder. Simply use that as a starting point and change what you want to change.

    Hope that helps.


  14. Gravatar

    Hi Mirjam,

    thank you for a great post.

    Please could you advice on how to scop the webtemplate to a site collection level. I dont want my web template to appear in the central admin's create site collection page.

    Also, i would like to enable my custom features after web is provisioned ... please could you advice what is the best approach to do this.

    Thanks in advance,


  15. Gravatar

    Hi Deepak,

    If you want to scope your web template to the site collection simply make sure you set the scope of the feature in which you deploy the web template to the Site scope.

    You can enable features on a site that is created by using a web template by adding the features in into the SiteFeatures or WebFeatures sections of the ONET.xml of your web template.

    More information on creating web templates can be found in this post:

    Hope that helps.


  16. Gravatar

    Hi All
    I have developed one custom solution in sharepoint 2010 foundation. I have only one site collection, and the root site only, that is team site. i have developed DMS and other functionality as per customer requirement. Now I want to deploy on customer site. Which approch should I do? I want that customer must not be able to redistribute the solution once deployed to his farm.


  17. Gravatar

    Using the SharePoint 2010 WebTemplate Feature Element for creating Site Templates

  18. Gravatar

    I require a way to create a Department Site (site collection level) and 3 of sub-sites for each department all from scratch.
    The Department Site and sub-sites require custom branding and each contain various libraries and differing page layouts.
    All home pages need to be customised with a slideshow (jquery)
    Also the entire Site collection, branding and hierarchy is to be mirrored for other departments eventually so the solution needs to be available.
    I was thinking of manually creating one area hierarchy using the browser adding in custom code and libraries and creating master page and page layouts. This way I can debug where required easily. Then create the sub-sites.

    Then, somehow exporting the 4 sites (1 site collection and 3 subs).
    Then either using Visual Studio or Poweshell create a solution to automate the build process for other departments.
    I think I need publishing feature enabled.

    Is this process about right?
    Can I export whole site collection as template or will I need to export individual webs?

  19. Gravatar

    Hi Raj,

    There is no good way to export configured sites like this.
    Possible options are:
    * "Save site as template" when the publishing features aren't enabled, but this is very instable, even without the publishing feature.
    * Use PowerShell to export sites. This only supported to actually replace the existing site, it's not meant to be used to replicate existing sites.

    The best and most stable option would be to write some code that creates these sites (you could create your own templating structure using XML so that your solution becomes more flexible).
    Another option is of course to create all sites manually.

    Sorry I don't have better news.


  20. Gravatar

    The surface of the rolex uk mechanical watch style bold and uninhibited, under the perspective of the rolex replica watches surface, diamond carbon film (ADLC) covering the black movement, sub black and fake omega bright black vividly on the filled. The ring hollow main plate and a main plate bridge table, proper blending, structured, coherent, exquisite craft of fake hublot watches Chanel watches are the ultimate pursuit of man is upright and show resolute personality.


Leave a Reply


Please add 2 and 5 and type the answer here: