Written by

Arut Selvan

Share

  

Category

see all categories
intranet as a service

Create SharePoint modern team site using site scripts and site designs

We know that some of the widely used features of SharePoint on-premises does not exists in the SharePoint Online. Site templates are one of them. But we usually have this question with us “what the solution is?”.   The solution is “Site designs”. In this article, we are going to see about how to create Site Designs and how can we use it to create team sites. We will be performing all the operations related to Site designing using PowerShell and SharePoint Online Management Shell.

Steps involved in creating a team site using SharePoint site designs with custom theming.

→ Generate Theme
→ Add Theme to the site
 Create Site Script
→ Add Site design
→ Create Team site

Generate Theme:

                Microsoft has provided an excellent Theme generator, through which we can easily generate a color theme for the site design. The generator gets the Primary color, Body text color,Body background color and generates the complete theme using the combination of related colors. The output of the generator will be in three types JSON, SASS and PowerShell. I am going to pick the PowerShell content. I have selected a Dark Red theme.

SharePoint Site templates

The output will be something like the below:

@{

"themePrimary" = "#be0000";

"themeLighterAlt" = "#080000";

"themeLighter" = "#1f0000";

"themeLight" = "#390000";

"themeTertiary" = "#730000";

"themeSecondary" = "#a80000";

"themeDarkAlt" = "#c61414";

"themeDark" = "#cf3232";

"themeDarker" = "#db6060";

"neutralLighterAlt" = "#0b0b0b";

"neutralLighter" = "#151515";

"neutralLight" = "#252525";

"neutralQuaternaryAlt" = "#2f2f2f";

"neutralQuaternary" = "#373737";

"neutralTertiaryAlt" = "#595959";

"neutralTertiary" = "#f6f2f2";

"neutralSecondary" = "#f8f4f4";

"neutralPrimaryAlt" = "#f9f6f6";

"neutralPrimary" = "#f2eaea";

"neutralDark" = "#fcfafa";

"black" = "#fdfdfd";

"white" = "#000000";

"bodyBackground" = "#000000";

"bodyText" = "#f2eaea";

}

Add Theme to the site:

        To add the above theme to the site, we can run the below PowerShell script. Make sure that you’re a tenant admin, before running the script.

SharePoint Intranet Software

Create a variable $themepallette and assign the object value which you received from the previous step.

$themepallette=               @{

"themePrimary" = "#be0000";

"themeLighterAlt" = "#080000";

"themeLighter" = "#1f0000";

"themeLight" = "#390000";

"themeTertiary" = "#730000";

"themeSecondary" = "#a80000";

"themeDarkAlt" = "#c61414";

"themeDark" = "#cf3232";

"themeDarker" = "#db6060";

"neutralLighterAlt" = "#0b0b0b";

"neutralLighter" = "#151515";

"neutralLight" = "#252525";

"neutralQuaternaryAlt" = "#2f2f2f";

"neutralQuaternary" = "#373737";

"neutralTertiaryAlt" = "#595959";

"neutralTertiary" = "#f6f2f2";

"neutralSecondary" = "#f8f4f4";

"neutralPrimaryAlt" = "#f9f6f6";

"neutralPrimary" = "#f2eaea";

"neutralDark" = "#fcfafa";

"black" = "#fdfdfd";

"white" = "#000000";

"bodyBackground" = "#000000";

"bodyText" = "#f2eaea";

}

Connect-SPOService -Url https://<your_tenant>-admin.sharepoint.com

Add-SPOTheme -Name "Dark Red" -Palette $themepallette -IsInverted $false

I have named my theme as Dark Red. After adding this theme to the site, we can be able to select it through the Change the look option of a modern team site.

template

After choosing the new theme, you can immediately see the change of look and feel. Select Apply to utilize the new theme.

Theme Template

But our intention is not to change it manually, instead utilize the existing the theme and apply it in our new modern team site.

Create Site Script:

                Site script is also a modern JSON file which helps in creating the site design. It will be in the below format.

{

    "$schema": "schema.json",

        "actions": [

            ...

            <one or more verb actions>

            ...

        ],

        "bindata": { },

        "version": 1 <to define the script version>

};

Some of the basic things which we can perform through site scripts are

→ Applying theme to the site
→ Creating list
→ Add/Delete SP Field
→ Add SP Field using XML
→ Add SP Lookup field using XML
→ Add/Remove SP View
→ Add/Remove Content type
→ Set SP Field Custom Formatter
→ Associate Field Customizer Extensions
→ Associate List View Command set Extensions
→ Add/Remove Navigations
→ Set site logo
→ Join a hubsite
→ Install an add-in or solution
→ Register an Extension
→ Configure Regional settings
→ Trigger a Microsoft Flow
→ Add users to SP Group
→ Manage guest access

The above things are mentioned in the Microsoft JSON Schema documentation. Below is the sample site script JSON which performs applying theme. I will be writing few more blogs to explain how to perform the remaining operations using site scripts.

{

"$schema": "schema.json",

"actions": [

{

"verb": "applyTheme",

"themeName": "Dark Red"

}],

"bindata": { },

"version": 1

};

To add a site script to Office 365 tenant, we need to execute the below PowerShell script after connecting to the tenant admin site using SPOService.

Get-Content '<folder_location_to_site_script>\SiteScript.json'-Raw | Add-SPOSiteScript  -Title "Dark Red Theme Site Script"

The above command would return site script ID(GUID), store it somewhere to mention it in the site design script.

GUID

Add Site design:

                The site design will be acting us the site template, which will define the structure for a customized team site. To add the site design to the Office365 we need to execute the below PowerShell script. Here we can mention multiple site scripts, which should be executed one by one. Right now, we have only one site script. I am including the site script ID after running it in the PowerShell ISE.

Add-SPOSiteDesign -Title "Custom site design" -WebTemplate "64" -SiteScripts " 0a42a67d-137a-4a07-8f37-e184c2703069" -Description "Creates a custom team site with the default dark red theme”

After execution, we will get response something similar to the below.

SPOSiteDesign

Create Team site:

As soon as we run the above script, the site design will be available as a template in the team site.

ThemeSite

While creating the team site, choose the custom site design template to see the magic. It will show the script which is executing on screen.

Team Site

The updated site will look like below.

SPO Theme

I hope you learnt how to apply theme using site designs. This helps the organization to maintain the same colour them, when creating each and every team site. Feel free to fill the comment box below.

Happy SharePointing!!!

Arut Selvan

Written by Arut Selvan

A technology enthusiast keen in learning & exploring new Microsoft technologies. Predominantly working on Microsoft 365, SharePoint & Azure. Currently working with "Hubfly - A unified digital workplace" as a Product Engineer, Arut brings in the new flavors of the technology to the product. He ensures we are always on the edge in our technology stack. He brings in innovation to the product with his out of the box thinking. He is also a Microsoft certified professional.