HOW TO: Customizing SharePoint AppWeb web template
This blog post is a contribution from Mustaq Patel, an engineer with the SharePoint Developer support team.
SharePoint Apps provides a great deal of flexibility and how much we can do with it. Using WebTemplate we can direct AppWeb (the SPWeb under which the App is hosted) to use any other Site Template instead of out of box “App” SiteTemplate.
All restrictions and other attributes that applies to WebTemplate in SharePoint 2010 or SharePoint 2013 sites, applies to WebTemplate in SharePoint Apps.
For information on WebTemplate in SharePoint apps see below article
https://msdn.microsoft.com/en-us/library/fp179925(v=office.15).aspx
For WebTemplates in SharePoint 2010 see below article
https://blogs.msdn.com/b/vesku/archive/2010/10/14/sharepoint-2010-and-web-templates.aspx#webtemplate
For this walkthrough we will apply Team Site (STS#1) template to Appweb that gets provisioned when SharePoint hosted app is deployed in onprem. Below are the steps
- Create a SharePoint hosted App project using VS2012.
- Right click the project in Solution Explorer and click > Add new item > Empty Element. Name it “CustomWebTemplate”.
- Go to \15\TEMPLATE\SiteTemplates\sts\xml and copy the ONET.xml file and paste it in the CustomWebTemplate folder that is created in the project as a result of the above step.
- Include the onet.xml to the project, make sure the deploymentType is ‘ElementFile’ in onet.xml’s properties window.
- Open onet.xml and we will start modifying it as below:
- Remove all <Configuration></Configuration> but the one with ID=0. In WebTemplate we can only have Configuration with ID=0.
- Remove all <modules></modules>. There should be no <modules> in a webtemplate.
- Remove <serverEmailFooter>
- Open the Elements.xml of CustomWebTemplate and paste below xml:
- Note that BaseTemplateName is the internal name of the site definition on which the web template ultimately derives. This is the value of the Name attribute of the template element in WebTemp*.xml file. BaseTemplateID is the value of the ID attribute of the template element in a WebTemp*.xml file.
- Right click AppManifest.xml and click > View Code.
- Before </Properties> copy below xml.
- Change FeatureId as per yours, it’s the ID of the feature that deploys the WSP in an App. You can get it by double clicking the .feature file in Features folder. This properties window has Feature ID.
- Also change the ID value in step 9 as per yours. It’s the combination of Feature ID that you got in step 10 and Name of the WebTemplate in WebTemplate element in step 6. Separate it with a hash symbol ( # ), also note the curly brackets ( {} ).
- Save all changes and deploy the app. Once deployed browse the app. You will notice that the App is now using team site template instead of App template. You will see familiar quick navigation and site settings.
Hope this helps!
Comments
Anonymous
January 01, 2003
I was able to get this to work on a plain SP app project (and even change the SiteLogoUrl in the ONET file.) However, I also experience app breakage when I add a workflow to the app and try to deploy:
ExceptionMessage: System.InvalidOperationException: Operation is not valid due to the current state of the object.Anonymous
October 20, 2013
mbakirov.wordpress.com/.../how-to-customizing-sharepoint-appweb-web-template-fixed-version-or-how-would-you-make-your-custom-default-master-page-into-your-sharepoint-appAnonymous
April 05, 2014
The comment has been removedAnonymous
October 03, 2014
This is all great. But when you add workflow the app breaks and cannot deploy.Anonymous
January 07, 2019
If you are having problems with workflows:The reason might be, that the feature "WorkflowServiceStore" is not activated in AppWeb.To do so, you can get the FeatureID by PowerShell (on the server) with Get-SPFeature -Identity WorkflowServiceStoreThen you modify ONET.XML like This was solving the workflow problem for me.