SP Site Design and Site Script

Why we should use Site Design and Site Scripts ?

As you know, most of corporate are believing in that consistency must be followed.
When new SharePoint sites are created in organization by employee based on their need, Organization need ensure some level of consistency most of the times.

For an instance, you may need apply proper branding and theming through out all sites no matter which template is being used, rather it is Team site, Communication site or any other custom template.

To achieve above scenario, Site design and Site scripts give us certain liberty to add default configurations or some default SharePoint artifacts and enable us to make same level of branding and navigation through out the all sites which is being created or which is already exist.

The article describes you how can you use Site design and Site Script to make new site with default configurations.

How Side Design works?|

Site design works same as Template like Traditional SharePoint Site Template.
It includes or accepts certain information with specific structure and specific tag which can help to identify the which needs to configured on given site.

They can used each time a new site is created to apply consistent set of actions.It can also be applied to existing modern site(Group Connected Team Site, Communication Site)
Most configurations majorly affect site it self such as applying custom theme or creating some SP list and Library.

Additionally, Site design also includes some other actions like Adding new created site information as a log, sending message to Ms Team to as a notification or sending a tweet.

You can create site design and register it with SharePoint online with any Site Template like Team Site and Communication Site.
With Communication Site, three site designs are already given by Microsoft.
1. Topic 2. Showcase 3. Blank

What is meaning of Site Scripts and How can use it with Site Design?
Site scripts are JSON files that include or specify an ordered list of actions or configurations which needs to execute when creating the new site or applying it to an existing site.

These actions must be run in ordered manner. In other words, sequentially process needs to follow while creating JSON file or Site Script.
Click here to get default JSON file for site script.
Each action in site script is specified by Verb value in JSON. For an instance, applyTheme  and createSPList .
How many actions are supported by Site Scripts?
Below actions are supported by site script.

  1. Creating a new list or library or modifying existing list and library.
  2. Creating site columns, content types and other list settings
  3. Site branding properties
    1. Navigation Layout
    2. Header Layout
    3. Header Background
    4. Applying Theme
    5. Setting a site logo
    6. Adding link to quick launch and hub site
  4. Triggering a Power automate flow
  5. Installing a deployed solutions from App catalog
  6. Setting regional settings of Site
  7. Adding User principals and group principals to SharePoint roles
  8. Setting external sharing capabilities

Click here, You can learn more about JSON objects.
Site scripts can be run again on the same site after provisioning.
Site scripts are non-destructive, so when they run again, they ensure that the site matches the configuration in the script.

For example, if the site already has a list with the same name that the site script is creating, the site script will only add missing fields to the existing list.

What are the limitations in Site Scripts?
1. Currently, You can add 300 actions or 100,000 characters when scripts are applied asynchronously.
2. There is also a limit of 100 site scripts and 100 site designs per tenant.

How to create Site Design and attach Site Script to it?
Developer can create site design and site scripts using Power Shell, PnP power shell and Rest API.
Click here to download sample site script which is created including some actions and store it in any directory.

Below Commad is used to add script SharePoint Online.

Get-Content 'c:\scripts\site-script.json'  -Raw | Add-SPOSiteScript  -Title "New Site Script"

You will get below Output once script is added to tenant.

Below command is used to create Site design and associate Site Script to it.

Add-SPOSiteDesign  -Title "Contoso customer tracking"  -WebTemplate "64"  -SiteScripts "2756067f-d818-4933-a514-2a2b2c50fb06"  -Description "Creates customer list and applies standard theme"

Title : Add name which you want to assign to site design
WebTemplate : You need to pass default web template id. 64 is for Team Site and 68 is for Communication Site.
SiteScripts : Pass Id of Site Scripts
Description : Provide Description
Once, command run successfully you can see your custom site design while creating new site as below.

How get all Site Scripts that is added in Tenant?
You can fire below command to SharePoint Online Management Shell


You can get below results.

Below command is used to get Site Designs which are added in Tenant

Get-SPOSiteDesign -Identity 6c70c4f6-e772-4877-ae1b-7270cc5cfd73

You will get below Output once command is fired successfully.

Reference Links:
Site Design Overview
Site Design JSON Schema
Site Design PowerShell
Site Design PnPPowerShell

I will write next blog to continue this feature to integrate with Power Automate and Add new entry in SharePoint list when new site is created.

Sharing is Caring 🙂

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.