Understanding Site Scripts and Site Templates: A Guide to Customizing SharePoint Sites
Introduction
For a complete list of available actions and their parameters, see the JSON schema.
What is a Site Script?
A Site Script is a JSON-based configuration file used in SharePoint Online to automate site setup and customization. Site Scripts work alongside Site Templates (formerly known as Site Designs) to provide a seamless, repeatable process for creating and configuring sites.
What Can a Site Script Do?
- Set site branding properties like navigation layout, header layout, and header background
- Applying a theme**
- Setting a site logo
- Adding links to quick launch or hub navigation**
- Triggering a Power Automate flow
- Installing a deployed solution from the app catalog
- Setting regional settings for the site**
- Adding principals (users and groups) to SharePoint roles**
- Setting external sharing capability for the site**
Creating a Site Script using PnP PowerShell
PnP PowerShell is a powerful tool that helps automate SharePoint operations. Below is a step-by-step guide to creating a Site Script using PnP PowerShell.
Step 1: Connect to the SharePoint Admin Center
To start, connect to the SharePoint Admin Center using the following script:
Step 2: Define the Site Script JSON
Below is an example Site Script JSON that creates a list named Document Creation and adds various fields:
Step 3: Add the Site Script to SharePoint
Run the following PowerShell command to add the Site Script:
Step 4: Create a Site Template using the Site Script
Once the Site Script is created, use it to generate a Site Template:
Step 5: Apply the Site Template to a New Site
Once you run the script successfully, you will see a confirmation message: "Site Template Created".
To apply this template, follow these steps:
Create a new site in SharePoint Online.
Choose Communication Site as the template.
Select From your Organization to apply the custom site template.
Your new site will be provisioned with the predefined settings, including lists, fields, and views.
Conclusion
Site Scripts and Site Templates provide a structured way to automate SharePoint Online site configuration. By using PnP PowerShell, administrators can efficiently create and manage Site Scripts, ensuring consistency across SharePoint sites. Whether setting up metadata structures, applying branding, or integrating automation, Site Scripts help streamline SharePoint site provisioning and enhance the user experience.
Comments
Post a Comment