How to Create a Custom Site Template in SharePoint Online

Introduction

Creating a custom site template in SharePoint Online is an effective way to standardize the structure, design, and content of multiple sites within an organization. This process is particularly beneficial for teams that require consistent layouts and functionalities across various projects or departments. Below, you will find a comprehensive guide on how to create a custom site template in SharePoint Online.

Step 1. Download and Install SharePoint Online Management Shell.

To manage your SharePoint Online environment using PowerShell commands, download and install the SharePoint Online Management Shell.

Download Link: SharePoint Online Management Shell

Step 2. Open and Connect to SharePoint Online PowerShell.

  • After installation, open the SharePoint Online Management Shell.
  • Connect to your SharePoint Online environment using the following command.
    Connect-SPOService -Url "https://YourDomain-admin.sharepoint.com"
    
  • Replace YourDomain with your actual SharePoint domain.

Step 3. Create the Site Script JSON.

To create a site script, you can either.

Step 4. Create the Site Design.

With your site script ready, you can now create a site design using PowerShell cmdlets. Execute the following commands to create the site script and assign it to a variable.

$SiteScript = $JSONScript | Add-SPOSiteScript -Title "Crescent Communication Site Script V1"

Next, create the site design that will utilize the site script.

Add-SPOSiteDesign -Title "Crescent Communication Template V1" `
                  -WebTemplate "68" `
                  -SiteScripts $SiteScript.ID `
                  -Description "Crescent Communication Site Template V1"

In this command, the WebTemplate parameter is set to "68", which corresponds to a Communication Site.

Complete PowerShell Script to Create a Site Template

Here is the complete PowerShell script to create a new modern site template for communication sites.

Script: # Define Site Script.

$JSONScript = @"
{
  "$schema": "schema.json",
  "actions": [
    {
      "verb": "applyTheme",
      "themeName": "Crescent Communication Theme V1"
    },
    {
      "verb": "setRegionalSettings",
      "timeZone": 4,
      "locale": 1033,
      "sortOrder": 25,
      "hourFormat": "12"
    },
    {
      "verb": "setSiteLogo",
      "url": "/Style Library/logo.png"
    },
    {
      "verb": "setSiteExternalSharingCapability",
      "capability": "ExistingExternalUser SharingOnly"
    },
    {
      "verb": "setSiteBranding",
      "navigationLayout": "Cascade",
      "headerLayout": "Standard",
      "headerBackground": "None",
      "showFooter": true
    },
    {
      "verb": "addPrincipalToSPGroup",
      "principal": "[email protected]",
      "group": "Members"
    }
  ],
  "bindata": {},
  "version": 1
}
"@

# Set Parameters
$AdminCenterURL = "https://crescent-admin.sharepoint.com/"

# Connect to SharePoint Online
Connect-SPOService -Url $AdminCenterURL

# Add Site Script
$SiteScript = $JSONScript | Add-SPOSiteScript -Title "Crescent Communication Site Script V1"

# Add Site Design
$WebTemplate = "68"  # 64 = Team Site, 68 = Communication Site, 1 = Team Site without Group
Add-SPOSiteDesign -Title "Crescent Communication Template V1" `
                  -WebTemplate $WebTemplate `
                  -SiteScripts $SiteScript.ID `
                  -Description "Crescent Communication Site Template V1"

Applying the Site Template

To apply your custom-designed site template, navigate to the SharePoint site where you want to use it. Select “From your organization” to find your custom template, then click “Use template.” You will see a notification indicating that the template is being applied. Once the process is complete, a message will confirm that the site template has been successfully applied.

Conclusion

Creating custom site templates in SharePoint Online streamlines the process of provisioning modern SharePoint sites with tailored actions and configurations. This approach not only saves time but also ensures consistency across multiple sites, enhancing collaboration and productivity