Create a SharepointOnline template and apply it to other sites: Step by Step guide.

Iron Contributor

Hi Community,

As I've been working on this for a recent ptoject, let me share with you this Step by Step guide to create a SPO template and apply it to new/existing SPO sites.


- We need to identify the site URL that we would like to use as template. ( Example: ).


- Connect to SPO from PowerShell, ( Connect-SPOService ), and create the necessary SiteScripts that we’ll need later to create our SiteDesign.

Basically, what we do in this step is to download and create the required scripts from our site in order to apply it later as a Custom template for new sites.


  • To create a SiteScript from an SPO site, you’ll need the site URL, the list/s URL’s and execute:


$extracted = Get-SPOSiteScriptFromWeb -WebUrl -IncludeBranding -IncludeTheme -IncludeRegionalSettings -IncludeSiteExternalSharingCapability -IncludedLists ("Shared%20Documents", "Lists/Project%20Activities")

Add-SPOSiteScript -Title "Contoso template site" -Description "This is a copy of a site collection." -Content $extracted


You’ll get an output like the following one. IMPORTANT: Note the ID as we’ll need it later for our SiteDesign.




- If we need only the configuration/Script of a list, ( or many lists ), we can do it like following: ( OPTIONAL )


$extracted = Get-SPOSiteScriptFromList -ListUrl

Add-SPOSiteScript -Title "Contoso Customer Tracker" -Description "This creates a customer contact list" -Content $extracted


IMPORTANT:  We can create as many we need for our case, for example one WebScript and different ListScripts from other sites if we need those list integrated.


- Now we have created the different SiteScripts that we need for our template. At this point, we need to add our custom Site Design to the tenant.

  • For that, execute:


Add-SPOSiteDesign -Title "DesiredName" -WebTemplate 64 -SiteScripts 2bf13764-19be-4ac4-9463-cb55d6fb1a55


IMPORTANT: Use WebTemplate 64 for Team Sites and WebTemplate 68 for Communication Sites.

The SiteScripts switch can be a single one or many ones separated by comma. The                            scripts run in the order listed.

You can use more options to personalize the template, like Description, Preview Image,                          Thumbnail Image… Example:


Add-SPOSiteDesign -Title "Contoso customer tracking" -WebTemplate "64" -SiteScripts "<ID>" -Description "Tracks key customer data in a list" -ThumbnailUrl "" -PreviewImageUrl "" -PreviewImageAltText "site preview"


  • The output of the SiteDesign cmdlt will be like the following one. Again it’s important to note the ID.



- Your created SiteDesign is now available to be implemented by PowerShell and also for the users when they create a new SPO site, from the Organization Templates option:





- In order to create a new PSO site from PowerShell and apply our Custom template, we can simply run the New-SPOSite with our desired options and then the Invoke-SPOSiteDesign cmdlt.

  • Example:
New-SPOSite -Url -title Test8 -Owner email address removed for privacy reasons -StorageQuota 2048 -Template STS#3 -NoWait

Invoke-SPOSiteDesign -Identity b9f0e526-583d-445a-b92b-664f494e42b6 -WebUrl


IMPORTANT: For the “Invoke” cmdlt, the “Identity” is the ID that we copied from our created SiteDesign and the “WebUrl” is our destination site, the new created one.


This will execute on your new created SPO site all the Site Scripts added to your Site Design, adding/adapting all the required content. Once done, the PS output will be something like this:




- Available templates to use with the New-SPOSite cmdlt:

  • Run “Get-SPOWebTemplate” to see a full list of the available ones and their description:


Now the new site is ready to use :) 




Get-SPOSiteScriptFromWeb (Microsoft.Online.SharePoint.PowerShell) | Microsoft Learn

Get-SPOSiteScriptFromList (Microsoft.Online.SharePoint.PowerShell) | Microsoft Learn

Add-SPOSiteDesign (Microsoft.Online.SharePoint.PowerShell) | Microsoft Learn

New-SPOSite (Microsoft.Online.SharePoint.PowerShell) | Microsoft Learn


0 Replies