Speaker : Mirjam Van Olst
With SP2007, web templates required to create a site definitions to be deployed in the 14 hives. Changes to the template needed a change to the site definition.
From SP2010, web templates can be changed afterwards even if sites were already created based on that template. Templates were also saved as a wsp files.
A web template can be Site and Farm scoped and uses the WebTemplate feature element. Only the onet.xml and elements.xml files are required. Site Template and Web Template can now be used interchangeably. They appear as the same to the user, no difference. “Save as a site template” creates a sandboxed solution, is stored in the site collection gallery and can be imported into Visual Studio. But, the import is difficult and it is probably better to create a new site definition. Web Templates are based on a site definition. It does not inherit from its based site definition. Saving a publishing site as a template is not supported.
Some Web template limitations : feature stapling can’t be used, and variations neither (would be the only reason why going for a custom site definition).
Web Template provisioning steps, first creates the URL for the site. Secondly, GLOBAL onet.xml file is provisioned. If site collection scope Web Template, the site collection features will be activated in the order they are declared in the onet.xml. For sub-site scoped Web Template, a check that site collection features are activated has to be done. Then, site scoped features are activated in the order they are defined in the onet.xml. Finally, list instances are created. If a feature needs to modify a list, as no list exist, it can’t be done like this. Therefore, list creation should be done during the feature activation (event receiver).
Web Template requires some properties : BaseTemplateName, BaseTemplateID and BaseConfigurationID. When starting a Web Template, it is recommended to take a copy of the Out-of-the-box onet.xml and to strip it rather than starting from scratch. A Web Template onet.xml can only contain one configuration. Configuration ID has to be 0. Modules element is not supported in onet.xml.
Recommendations : use only enough features and limit the number of features that need to be activated (slowness of site provisioning). Be careful, site scoped features can block sub-site creation.
Two ways to deploy Web Template : Farm solution, or sandboxed solutions. Farm solution way makes the Web Template being available in the whole environment. The last solution will keep the onet.xml and elements.xml files will be stored in the content database. When using Sandboxed solution, it can also be deployed in Office 365. In most of the cases, everything done in a Web Template can be put in a Sandboxed solution. But, make sure that the solution can be removed after a site has been created.
Web Template can be used from code to provision new sites, using the web template feature GUID and name, separated by the sharp sign. It is also a good thing to store the web template and version of the property bag (<PropertyBag> element) of the site.
A webtemp file can be linked to several site definitions.
Apps for SharePoint must be self-contained.
The domain of the App Web is different from the one the user is browsing (Host Web). Creating App Web can be done starting from the App-0 site definition. It is also possible to create the App Web using a custom Web Template. It is deployed in the App itself in a web scoped feature. It has to be defined in the appmanifest.xml file.