We know that some of the widely used features of SharePoint on-premises do not exist in SharePoint Online. Site templates are one of them. But we usually wonder what the solution is. The solution is “Site designs”. In this article, we are going to see 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 themes.
- 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.
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.
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:
- Add - SPOTheme - Name "Dark Red" - Palette $themepallette - IsInverted $false
I have named my theme dark red. After adding this theme to the site, we can select it through the change option of a modern team site.
After choosing the new theme, you can immediately see the change of the look and feel. Select apply to utilize the new theme.
But our intention is not to change it manually; instead, utilize the existing theme and apply it to 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 the theme to the site
- Creating a 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 hub site
- 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 applies the theme. I will be writing a 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), and store it somewhere in the site design script.
Add Site designThe site design will be acting as 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 "Custa om 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 a response similar to below.
Create Team siteAs soon as we run the above script, the site design will be available as a template in the team site.
While creating the team site, choose the custom site design template to see the magic. It will show the script which is executing on the screen.
The updated site will look like below.
I hope you learned how to apply a theme using site designs. This helps the organization to maintain the same color theme when creating each and every team site. Feel free to fill in the comment box below.
Happy SharePointing!!!