SharePoint site designs and site scripts

SharePoint users and administrators have long appreciated the opportunity to reuse SharePoint "Site Templates".

Site scripts

Microsoft site scripts allow users and administrators to automate the provisioning of "similar" SharePoint sites.

Site scripts are JSON formatted files.

Site scripts include "actions" that will modify a SharePoint site. 

Site script actions include:

  • Add Nav Link
  • Apply Theme
  • Create Content Type
  • Create Site Column
  • Create SharePoint List
  • Install Solution
  • Join Hub Site
  • Remove Nav Link
  • Set Regional Settings
  • Set Site Branding
  • Set Site Logo
  • Set Site External Sharing Capability
  • Trigger Flow
Example site script

Add-SPOSiteScript

Site scripts are added to a SharePoint tenant using the Add-SPOSiteScript command

Connect to the SharePoint administration site

Load the JSON text into a variable

Add-SPOSiteDesign

Site designs can extend the SharePoint modern team site template(64) or the SharePoint modern communication site template (68).

Site designs are added to a SharePoint tenant using the ADD-SPOSiteDesign command (specifying one or more Site Script ids)

Add the Site Script and add the Site Design

SharePoint Create a Site

Once the Site design has been created the out of the box "Create a Site" user experience will be updated

Select "Team Site" because the new Site Design is based on the team site template(64)

The "Contoso customer tracking" Site Design is available in the "Choose a design" drop down list.

Click the Finish button to create the new Site and to run the Site Scripts

The newly created site includes the "Customer Tracking" list

Applying a site design to an existing site

The Get-SPOSiteDesign command can be used to list the installed Site designs (and the ids assigned).

Site designs can be applied to an existing SharePoint site using the Invoke-SPOSiteDesign command.

Site contents before invoking site design

Invoke-SPOSiteDesign

Site contents after invoking site design

Get-SPOSiteScriptFromWeb

The Get-SPOSiteScriptFromWeb command extracts Site Script from an existing SharePoint site.

Running the Get-SPOSiteScriptFromWeb command

Get-SPOSiteScriptFromWeb results