How to Create a Site Template in SharePoint Online?

SharePoint Online offers a powerful feature called Site Templates, which allows users to automate the provisioning of modern SharePoint sites with custom or pre-defined configurations and content. With Site Templates, you can maintain consistency across your site collection, including themes, lists and libraries, site columns and content types, association with hub sites, and security settings. In this article, we will explore the process of creating and applying site templates in SharePoint Online.

Understanding SharePoint Site Templates

Site Templates, formerly known as Site Design, serve as starting points for building SharePoint sites. Microsoft has revamped the user interface for site templates, making it easier than ever to create custom sites within minutes. These templates not only include default Microsoft SharePoint templates, but also allow you to create custom templates tailored to your organization’s specific workflows and business processes. By leveraging site templates, you can save time and ensure consistency in site design, branding, functionality, and content across your SharePoint Online environment.

While the Classic site templates, such as team sites, publishing sites, and document centers, are based on the traditional SharePoint platform, the modern site templates, including communication sites, group sites, etc., are built on the new SharePoint framework. Classic site templates offer “Save site as Template” functionality for creating site templates, Site Scripts, and Designs are the way to customize modern site templates in SharePoint Online.

Through Site scripts, You can perform the below activities:

  • Create a new list or library.
  • Create site columns, content types, and configure list settings
  • Apply a theme.
  • Set branding properties like navigation layout, header layout, and header background
  • Set a site logo
  • Adding links to quick launch or hub navigation
  • Trigger a Power Automate flow
  • Set regional settings for the site
  • Add users and groups to SharePoint roles
  • Set external sharing capability for the site
  • And more.

Creating a Custom Site Template – Step by Step

Creating a custom site template involves using site scripts and PowerShell cmdlets to define the action, content, and configurations for your template. Site scripts are JSON files that specify the actions SharePoint should perform when creating a new site. These actions can include creating lists, applying themes, joining hub sites, and more. Let’s explore the process of creating a simple site template that applies certain configurations to the site. Here is a step-by-step guide to creating a customized site template in SharePoint Online:

Step 1: Download and Install SharePoint Online Management Shell

Before you begin, make sure you have the SharePoint Online Management Shell installed on your system. If you already have a previous version installed, make sure it’s up-to-date. How to Install SharePoint Online Management Shell?

Step 2: Connect to SharePoint Online PowerShell

Once you have the SharePoint Online Management Shell installed, you need to connect to your SharePoint tenant using PowerShell. Use the Connect-SPOService cmdlet to connect to SharePoint Online from PowerShell.

Connect-SPOService -Url "https://YourDomain-admin.sharepoint.com"

Step 3: Create the Site Script JSON

A site script is a collection of actions that SharePoint executes when creating a new site. These actions are defined in a JSON script, which lists all the actions to apply in the desired order. Each action is specified by the “verb” value in the JSON script. You can refer to the Site Script Schema to create the script, But there is an easier way with this tool: https://www.sitedesigner.io. Just select the actions, and get the JSON generated!

For example, let’s create a site script that sets the site theme, logo, timezone, External sharing settings, navigation configurations, and add a user account “Helpdesk@Crescent.com” to the associated member’s group of the site. Here’s an example JSON script for the site script:

{
  "$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": "ExistingExternalUserSharingOnly"
    },
    {
      "verb": "setSiteBranding",
      "navigationLayout": "Cascade",
      "headerLayout": "Standard",
      "headerBackground": "None",
      "showFooter": true
    },
    {
      "verb": "addPrincipalToSPGroup",
      "principal": "Helpdesk@Crescent.com",
      "group": "Members"
    }
  ],
  "bindata": {},
  "version": 1
}

Step 4: Create the Site Design

Now that you have the site script defined, you can create a site template using PowerShell cmdlets. Execute the following PowerShell code 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 use the site script:

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

The WebTemplate parameter specifies the base template for the site design. In this example, we are using the “68” template, which represents a Communication Site.

PowerShell Script to Create a Site Template in SharePoint Online

Here is the complete version of the script to create a new modern site template for communication sites:

#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": "ExistingExternalUserSharingOnly"
    },
    {
      "verb": "setSiteBranding",
      "navigationLayout": "Cascade",
      "headerLayout": "Standard",
      "headerBackground": "None",
      "showFooter": true
    },
    {
      "verb": "addPrincipalToSPGroup",
      "principal": "Helpdesk@Crescent.com",
      "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"

Now, you can navigate to the SharePoint site where you want to apply the site template, go to Site Settings, and select “Apply a Site Template.” Choose the “From your organization” option, and you should see your newly created site design listed. Select it to apply the site template to the site.

How about getting existing site templates, updating the site scripts, setting the default site design, or removing site templates? Refer: SharePoint Online Site Scripts and Site Designs

Applying Site Templates

To apply a site template in SharePoint Online, navigate to the Site’s Settings menu and select “Apply a Site Template.” You will be presented with two options:

  1. From Microsoft: This option displays templates from the lookbook, a collection of scenario-based SharePoint Online templates. These templates are designed to cater to different use cases, such as team collaboration sites or communication sites. The templates from Microsoft’s lookbook can be a great starting point for your SharePoint sites.
  2. From your organization: This option allows you to access and apply custom-designed site templates specific to your organization’s needs. These templates can be created and customized to align with your branding, content, and business processes.
create a site template sharepoint online

Select “From your organization” to choose your custom-designed site template, and click “Use template”. Wait for the template to be applied to the site.

sharepoint online site templates

As soon as you click on the “Use site template” button, you’ll find a notification banner with the text “Applying site template. We’re updating your site based on a pre-selected template. View progress” and then the message: “Site template applied. Refresh this site to see the changes.”

Benefits of using SharePoint site templates

There are several benefits to using SharePoint site templates. Firstly, they enable organizations to standardize their site designs and branding, ensuring a consistent look and feel across all sites. This not only improves the user experience, but also helps reinforce the company’s brand identity.

Secondly, SharePoint site templates simplify the site creation process. Instead of starting from scratch every time a new site is needed, users can simply select a template that best fits their requirements. This saves time and effort, allowing users to focus on adding content and customizing the site to their specific needs.

Lastly, SharePoint site templates promote collaboration and knowledge sharing. By providing pre-configured settings and content, templates make it easier for teams to collaborate on projects and share information. This can greatly enhance productivity and improve communication within an organization.

Conclusion

Creating site templates in SharePoint Online provides a powerful way to automate the provisioning of modern SharePoint sites with custom actions and configurations. By leveraging PowerShell cmdlets and site scripts, you can define the desired actions and apply them consistently across your site collection. Whether you need to create a custom list, apply a theme, or configure site navigation, site templates offer a streamlined and efficient approach to site provisioning. Start exploring the possibilities of site templates in SharePoint Online and unlock the full potential of your SharePoint environment.

Salaudeen Rajack

Salaudeen Rajack - Information Technology Expert with Two-decades of hands-on experience, specializing in SharePoint, PowerShell, Microsoft 365, and related products. He has held various positions including SharePoint Architect, Administrator, Developer and consultant, has helped many organizations to implement and optimize SharePoint solutions. Known for his deep technical expertise, He's passionate about sharing the knowledge and insights to help others, through the real-world articles!

3 thoughts on “How to Create a Site Template in SharePoint Online?

  • Do you need to specify the company logo for Team Sites? What about Communication Sites? What happens if you don’t, does it just default to the company logo anyway?

    Reply
  • I am also interested in how to include the contents of a list and/or library using these scripts.

    Reply
  • Hello Salaudeen,
    Great post and quite detailed. It is very helpful. Thank you for putting it together. Had couple of questions on you process.
    1. Can content be included while creating a custom template using your above process.
    2. Does the Site Script and Site Design just creates the elements of list and library and adds it in the site contents section or it also brings it together and inserts in the template page.
    Looking forward to your feedback.

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *