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

For WebTemplates in SharePoint 2010 see below article

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

  1. Create a SharePoint hosted App project using VS2012.
  2. Right click the project in Solution Explorer and click > Add new item > Empty Element.  Name it “CustomWebTemplate”.
  3. 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.
  4. Include the onet.xml to the project, make sure the deploymentType is ‘ElementFile’ in onet.xml’s properties window.
  5. Open onet.xml and we will start modifying it as below:
    1. Remove all <Configuration></Configuration> but the one with ID=0.  In WebTemplate we can only have Configuration with ID=0.
    2. Remove all <modules></modules>.  There should be no <modules> in a webtemplate.
    3. Remove <serverEmailFooter>
  6. Open the Elements.xml of CustomWebTemplate and paste below xml:
  7. 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.
  8. Right click AppManifest.xml and click > View Code.
  9. Before </Properties> copy below xml.
  10. 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.
  11. 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 ( {} ).
  12. 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 (5)
  1. Anonymous says:

    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.

  2. web development says:

    This is a good article & good site.Thank you for sharing this article. It is help us following categorize:
    healthcare, e commerce, programming, it consulting, retail, manufacturing, CRM, digital supply chain management, Delivering high-quality service for your business applications,
    Solutions for all Industries,
    Getting your applications talking is the key to better business processes,
    Rapid web services solutions for real business problems,
    Web-based Corporate Document Management System,
    Outsourcing Solution,
    Financial and Operations Business Intelligence Solution,“>prologic-corp

  3. George says:

    This is all great. But when you add workflow the app breaks and cannot deploy.

  4. TomS- says:

    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 WorkflowServiceStore

    Then you modify ONET.XML like

    This was solving the workflow problem for me.

Comments are closed.

Skip to main content