15 August 2016

How do I - Create a SharePoint 2013 sub site template when the UI option is not there?

SharePoint's publishing infrastructure and Features have been the bane of many a debug session I've been involved in.  SharePoint sites just behave differently when publishing is turned on.  Along with this, comes some menu and settings differences that Microsoft enforces for publishing sites.  Good, bad or indifferent, these nuances require some unique workarounds from time to time.

I have a client who is using publishing as part of their base site template.  Now the client wants to create a site template from a given sub site.  The template would then be used to create other sub sites in the same site collection.  Without publishing, this is no problem as you simply navigate to the Settings Gear > Site Settings > Site Actions > Save as template.  When publishing is turned on however, this option disappears from the settings page.
No problem you think.  I'm a smart and attentive SharePoint guru and I know what the "Save as template" page's URL is.  I'll just manually type it into the browser's address bar.  So you proceed to manually add _layouts/15/savetmpl.aspx to the current site URL so it would read something like this:
With confidence you press the key on your keyboard and...

This is one of those little settings Microsoft made while trying to "protect" you from yourself.  OK, so how do we work around this one?
It's actually pretty easy once you know how the underlying process functions.  The "savetmpl.aspx" page does a lookup at the site property bag to see if there's a specific variable defined.  The variable is called "SaveSiteAsTemplateEnabled".  If it's defined, its value is checked and if set to "false", then the above error message is thrown and the template save process is aborted.
That said, we can work around this by using SharePoint Designer to change the variable value.  Here are the complete steps to overcome this little problem:
  1. Open SharePoint Designer 2013. 
  2. Open your target site e.g. http://www.crayveon.com/sites/PublishingSite1/SubSiteA  
  3. In the ribbon at the top, on the far right, click "Site Options". 
  4. On the Site Options dialog, under the "Parameters" tab, you will notice the target variable in question... "SaveSiteAsTemplateEnabled".  Its value should read "false".  Select the variable and click the "Modify" button on the right. 
  5. Change the value to "true" and click "OK". 
  6. Click "OK" to close the Site Options dialog window.
  7. From your browser, navigate to the target site e.g. http://www.crayveon.com/sites/PublishingSite1/SubSiteA
  8. From the target site, add "/_layouts/15/savetmpl.aspx" to the URL of the site e.g. http://www.crayveon.com/sites/PublishingSite1/SubSiteA/_layouts/15/savetmpl.aspx and press Enter.
  9. You should be presented with the Save as Template page. 
  10. Fill out your desired options and click "OK" to save the template.
Provided you don't have any custom apps on the site that are not compatible with templatization, the result should be successful.  If you do have custom apps, you'll have to remove said apps and then try saving as a template again.


SharePoint Remote Event Receivers are DEAD!!!

 Well, the time has finally come.  It was evident when Microsoft started pushing everyone to WebHooks, but this FAQ and related announcement...