2

Is there a way to save site as a template if you are using Modern sites? I have followed some tutorials online where you use a script to enable scripting on site. I have also made sure if the Publishing features are disabled.

Is there a way to save modern sites as template. It was easy to do in Classic sites. Is this even an option for modern sites?

1

We can save the modern site (modern team site and communication site) as the site template by visiting /_layouts/savetmpl.aspx page.

When you access /_layouts/savetmpl.aspx , access denied may occur. It occurs because the denyaddandcustomizepages of this site is true. DenyAddAndCustomizePages determines whether the Add And Customize Pages right is denied on the site collection. By default, the right is denied on the modern site collection.

We need to connect to SharePoint Online using PowerShell and set denyaddandcustomizepages of the site to false.

$adminUPN="<admin>@<tenant>.onmicrosoft.com"
$userCredential = Get-Credential -UserName $adminUPN -Message "Type the password."

Connect-SPOService -Url https://<tenant>-admin.sharepoint.com -Credential $userCredential
set-sposite https://<tenant>.sharepoint.com/sites/<communication/team> -denyaddandcustomizepages $false

Ten, you can access /_layouts/savetmpl.aspx page and save the site as template.

  • Is this recommended approach? – George 2 hours ago
2

No, Modern Team/Communication sites do not support the save as template function -- in part because it was a bad idea in the first place, and because they have Publishing functionality enabled at all times with no ability to disable it.

The closest you can come to template-like functionality is via Site Designs.

  • thank you @trevor. Let me go through the article and see if it helps me. – hkhan Jan 14 at 22:19
  • as far as my understanding goes, you need to create a site design of a site you plan to use as a template and then apply that design to other sites. Am i correct? Is there a tool that builds this schema for you for a SP site? – hkhan Jan 15 at 0:25
  • I'm not aware of a tool that builds it for you. But you have it more or less correct. Site Designs can be extended via Azure Functions and Microsoft Flow, as well. – Trevor Seward Jan 15 at 0:31
0

First, go-to your sharepoint admin central and allow custom scripts in the settings section

enter image description here

Now, in the SharePoint online management shell, run the following powershell commands one after the other

Import-Module Microsoft.Online.SharePoint.PowerShell -DisableNameChecking

Connect-SPOService -Url https://yourname-admin.sharepoint.com/

This will prompt for user name and password

Set-SPOsite "https://yourname.sharepoint.com/sites/yoursite" -DenyAddAndCustomizePages 0

Once you run this, you should be able to save your site as template by visiting site settings and clicking on "Save site as Template"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.