Save publishing site as a template

Save your newly created SharePoint site as a template can save you a lot of time if you want to replicate it again in your environment.

Unfortunately if you used a Publishing Site or if you had to activate the Publishing Features in a Collaboration Site, save site as a template will not be available.

In this article I explain all the steps to bring back this feature to the publishing sites and also the extra steps you may need to activate all site features.

Save Site as Template - SharePoint

Info: The solution described in this article is still valid however there are more eficient ways to create site templates using the latest technologies for SharePoint, you can lern more about it in this article.
  1. Open the site with SharePoint Designer
  2. In the ribbon go to Site Options
  3. Locate the option SaveSiteAsTemplateEnabled and modify the value to true
  4. Since the site template is disabled in the Publishing sites the option Save Site as Template is not available in the Site Settings you will need to navigate to the page directly: http://yourdomain.sharepoint.com/_layouts/savetmpl.aspx
  5. Provide all the details and click OK after a couple of minutes you will have the WSP site template generated

    If the operation succeeds you will see the screen bellow

    Note: If you have apps downloaded from the store they could prevent you to save the site as a template if you are facing this scenario you will need to uninstall the apps first.

  6. Open the Solution Gallery and click in the template name to download the wsp file containing the site template


Create a site based on the new template


  1. Open the site collection where you want to install the site template. If you have other sandbox solutions installed in the original site collection you will need to install them first in the new site collection
  2. Open the Solution Gallery to upload and activate the site template wsp
  3. Go to Site Contents and create a new subsite
  4. Provide all the details and select Custom in the Select a Template option
  5. Select the template name and click Create, it may take a few minutes
    If the site creation fails, you will see an error message like this and you will need to activate the missing features.


Activate missing features

Most of the missing features can be activated in the Site Settings and to do that you have a graphical interface. If the required feature is not available in the features list, you can follow the steps bellow.

Office 365

You can activate features from SharePoint Online using a PowerShell script, the script and the required dll files can be downloaded from here.

  1. Extract the files from the zip
  2. Edit the PS1 file
  3. Modify the variables to connect to your SharePoint
    $sUserName: User Name to connect to the SharePoint Online Site Collection
    $sPassword: Password for the use
    $sSiteColUrl: SharePoint Online Site Collection
    $sFeatureGuid: GUID of the feature to be enabled
  4. Run the script
  5. After all features have been activated you will be able to create your custom site


SharePoint 2013 and SharePoint 2016

  1. On the SharePoint server open the command line as Administrator
  2. Type the following command cd C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\15\BIN”
  3. Type the following command stsadm -o activatefeature -id -url
  4. Replace the feature-guid by the feature ID, depending of your SharePoint version it can be presented as a correlation ID
    Replace the site-collection-url by the site collection url where you want to activate the feature

  5. After all features have been activated you will be able to create your custom site

16 Responses to “Save publishing site as a template”

  1. Norbert

    January 27, 2017

    I try using the savetmpl.aspx but as soon as the page opens it redirects to the home page of the site.

    Any tips?

    Reply
  2. DA Employee

    March 6, 2017

    This does not work if there are downloaded apps as you mentioned, and you suggested to uninstall them first. Uninstalling these apps may not be a SOUND suggestion. Have you tried it? Most of these apps were downloaded to be used in the site to begin with. Their removal deletes their instances, if not displaying error(s), in the site.

    Reply
    • João Ferreira

      March 7, 2017

      Hi,

      Yes I tried it, please notice that this is just a work around and may not work for all scenarios.
      What I do is uninstall the apps if necessary and then reinstall then in the new site.

      Reply
  3. Florian

    March 29, 2017

    This worked for me. Unfortunately the homepage (in my case default.aspx) is empty. It’s an article page with customized pagelayout. Is there a way to get a 1:1 copy of this page?

    Reply
    • João Ferreira

      March 29, 2017

      Hi Florian,

      Yes it’s possible you can follow this article to reapply the custom page layouts after the site creation.
      http://sharepoint.handsontek.net/2017/01/29/fix-publishing-pages-with-custom-page-layouts-created-from-template/

      Reply
      • Florian

        March 29, 2017

        Hi João,
        if I understand your post right. This will be only applicable _after_ the site is created with the custom site template, right? So there is now handy way to prevent this behaviour?

        Reply
        • João Ferreira

          March 29, 2017

          You understood it correctly the behaviour will not be preserved, it will always require a manual intervention to get the correct page layout to display.
          I have not found any other way to implement site templates with publishing sites, but there are new alternatives to this process.
          I never tested them so I don’t know if they will preserve the behaviour of the site, have a look at the links bellow:
          https://templates-gallery.sharepointpnp.com/
          https://github.com/SharePoint/PnP-Provisioning-Schema/wiki

          Reply
          • Florian

            April 12, 2017

            Hey João,

            it’s me again. 😉
            Your post blogs really helped me out. But there’s just one little thing which lets me bang my head against the desk: Applying my custom master page. It is allready available at sitecollection level but against the law af inheriting the newly (by template) created subsite just shows up with seattle.master. The configuration is just fine (so it will inherit master page, page layouts, etc.) but I have to go on sitecollection level and “deploy” the master page over all subsites again.
            I tried this: http://jeffreypaarhuis.com/2011/10/21/your-master-page-automatically-on-newly-created-subsites/ combined with https://blogs.msdn.microsoft.com/bgeoffro/2009/06/22/master-pages-revisited-references-to-master-pages-in-sharepoint/ so the ONET.xml configuration looks like this:

            I don’t call for support, but maybe you have a hint for me, where to look for more information?!

          • João Ferreira

            April 13, 2017

            Hey Florian,

            Never experienced this before as long as the master page is deployed in the root site of the site collection all the sub sites created from template or not should inherit them.
            If you have installed the custom master using a wsp also make sure that the solution is active.
            Check with SP designer if the master pages are located under All Files -> _catalogs -> masterpage, if you have the masters check them out, check them in again and publish as major version.
            Let me know if you discovered the cause of the issue.

          • Florian

            May 15, 2017

            Hey João,
            so far I didn’t find the cause. But I (or better say my colleque) found a way to solve it. Luckily he also found a way to automate the way how to fix the publishing page fail (as you mentioned in this post http://sharepoint.handsontek.net/2017/01/29/fix-publishing-pages-with-custom-page-layouts-created-from-template/). So both is combined now and my customer can use his template with all customizations but without skripting, without coding and luckily without any long ways to click and reset page layouts.
            The trick is to translate your script (http://sharepoint.handsontek.net/2017/01/29/fix-publishing-pages-with-custom-page-layouts-created-from-template/) into JSOM. This js-file can be called from a simple aspx-page (like the AllItems.aspx from a custom list) which is by default your welcome page (you can set the value it in site settings). The rest does the script. There you can define where the masterpages are and set them.

          • João Ferreira

            May 31, 2017

            Florain,

            I’m glad to know it worked, I’ll test it my self and I’ll try to update this article.

  4. Melani

    May 11, 2017

    Hey João,
    Thanks for this, very helpful. I have a little issue though.
    Once I create the site, I get a “Page not found” error. I can modify the URL and then go to “Site contents” and see that the site has been created. I have a custom master page in place that should be inherited? Any ideas?

    Thanks!

    Reply
  5. feartheswamp

    January 29, 2019

    You can copy a publishing site in Content and Structure. It is not a template but if you create a site like you want it you can go to Site Settings > Content and Structure and copy the site

    Reply
  6. Krutika

    March 24, 2019

    Hi João,

    I did this and got it working good. However, when I did include with content, the documents in the template are having same document ID , resulting in error while clicking on document. Any workarounds for this ? Any ideas ?

    Thanks!

    Reply
    • João Ferreira

      March 26, 2019

      Hi Krutika,

      While this workarround is a valid solution for some specific scenarios it has issues like the ones you are describing, and this is why Microsoft have it blocked.
      I wrote another article with a more robust solution, you can find instructions here , however it will require you to add the content manually to the template.

      Reply

Leave a Reply to Melani


I've been working with Microsoft Technologies over the last ten years, mainly focused on creating collaboration and productivity solutions that drive the adoption of Microsoft Modern Workplace.

%d bloggers like this: