Modern SharePoint Site Templates Ft. Site Designs and Site Scripts

Modern SharePoint Site Templates Ft. Site Designs and Site Scripts

Eric Gregorich

SharePoint has had the capabilities to create Site Templates since early on-premises versions. SharePoint Online kept this functionality, but with the introduction to modern sites, we needed something better.

SharePoint Online supports what Microsoft calls Site Designs. These Site Designs are composed of Site Scripts, which are instructions written in JSON for creating a portion of the site collection structure. Today, we create these Site Designs using PowerShell. Once created, we can apply the Site Designs to any existing SharePoint Online site.

Microsoft is currently rolling out (as of July 2021) updates to the UI for applying these Site Designs. They're now calling them Site Templates again, which makes sense. I assume someday we'll have the ability to save an existing modern site as a Site Template without needing to use PowerShell.

To use Site Designs you:

  • Create your template site
  • Execute some PowerShell to create the Site Scripts from the template site.
  • Execute some PowerShell to create the Site Design composed of Site Scripts.
  • Apply the Site Design to your site(s).

Create your Template Site

Unless you get great joy from writing your own JSON, you'll likely want to start by creating a site collection in SharePoint and create all of the lists and libraries you want the easy way. For each list and library, all of its columns, views, and settings will be included.

You don't need to create a dedicated site collection to act as your template. If you have an existing site that has one or many lists and libraries you want to use, you can create the Site Design from that as well.

Create a Site Design

Once you have a site collection created, you'll execute some PowerShell to create the Site Design in your tenant.  The following PowerShell covers the basics for creating a couple of Site Scripts and a Site Design. The Microsoft Docs go into more detail.

Install-Module -Name Microsoft.Online.SharePoint.PowerShell
# ===========================================================================
# # ===========================================================================
$varTemplateAdminUrl = ''
$varTemplateSiteUrl = ''

# # ===========================================================================
# # ===========================================================================
Connect-SPOService -Url $varTemplateAdminUrl
$siteScriptLibraries = Get-SPOSiteScriptFromWeb -WebUrl $varTemplateSiteUrl -IncludedLists ("Shared%20Documents")
$siteScriptLists = Get-SPOSiteScriptFromWeb -WebUrl $varTemplateSiteUrl -IncludedLists ("/Lists/Issue%20tracker", "Lists/Employee%20onboarding")

# # ===========================================================================
# # ===========================================================================
$siteScriptLibrariesResult = Add-SPOSiteScript -Title "Department Site Libraries" -Content $siteScriptLibraries
$siteScriptListsResult = Add-SPOSiteScript -Title "Department Site Lists" -Content $siteScriptLists

Add-SPOSiteDesign -Title "Demo Department Site" -WebTemplate "64" -SiteScripts $siteScriptLibrariesResult.Id, $siteScriptListsResult.Id -Description "Creates department site library and lists."
  • The Power Shell needs to be run as an administrator.
  • First, we install Microsoft.Online.SharePoint.PowerShell module. You don't need to do this if you use the SharePoint Online Management Shell instead.
  • Next, we set some variables. The first is your admin center URL. The second is the URL to the site from which you want to create the template.
  • In the above example, I'm creating two Site Scripts—one for the Document Libraries and another for the Lists. We could combine them, but I wanted to demonstrate multiple site scripts for a single Site Design. If your site uses any lookup lists, create those separately in their own site script before any lists or libraries which use those lookup lists.
  • Finally, we'll add the new Site Design to the tenant.
You'll want to look through the documentation for more options if you're doing more than create some lists and libraries. You have many more options, including launching a workflow in Power Automate!

You can also view existing site scripts:


Or existing site designs:


And, of course, you can update an existing Site Design.

Get-Content $siteScriptXML Set-SPOSiteScript -Identity "3747dd8c-f161-4340-be75-d6e5b16bc5de" -
Set-SPOSiteDesign -Identity 'a54388af-063e-4662-b340-e2500ee74902' -SiteScripts "3747dd8c-f161-4340-be75-d6e5b16bc5de" -Version 2

Applying the Site Template

  • Open the Site Settings panel and look for the Apply a site template link.
  • You'll first see several templates from Microsoft.
  • Click on the "From your organization" tab to see any Site Templates your organization has created.
The new Select a template dialog in modern SharePoint sites.
If you don't see the Apply a site template link, it is either not available yet, or you don't have permissions. If you see a link for Site Designs, click that instead. It does the same thing, but the UI is older in the latter.

Additional Resources

SharePoint site design and site script overview
Use SharePoint site scripts and site designs to provide custom configurations to apply when new sites are created.
Repository for sample SharePoint site designs and site scripts - pnp/sp-dev-site-scripts