SharePoint Online: How to Create a Site Design from an Existing Site Using PowerShell?
As a SharePoint expert, I’ve seen the tremendous value that site designs bring to organizations looking to streamline their site creation process and maintain consistency across their SharePoint environment. One of the most powerful features of site designs is the ability to create them based on existing sites, allowing you to capture and replicate the structure, settings, and, optionally, the content of a well-crafted site. In this comprehensive guide, I’ll walk you through the process of creating a site design from an existing site in SharePoint Online, providing step-by-step instructions and best practices to help you harness the full potential of this feature.
Understanding Site Designs in SharePoint Online
Before we dive into the process of creating a site design from an existing site, let’s take a moment to understand what site designs are and why they’re so valuable in SharePoint Online.
What are Site Designs?
Site designs are pre-configured templates that define the structure, settings, and content of a SharePoint site. They allow you to create consistent, standardized sites quickly and easily, without the need for manual configuration or customization. They act as blueprints that save time and reduce the margin for error, ensuring that each site within your organization adheres to set standards and practices.
Benefits of Using Site Designs
- Consistency: Site designs ensure that all sites created from a particular design have a consistent look, feel, and structure, promoting a unified user experience across your SharePoint environment.
- Efficiency: By using site designs, you can significantly reduce the time and effort required to create new sites, as the design takes care of the initial setup and configuration.
- Governance: Site designs help enforce governance policies and best practices by providing a controlled, standardized way to create sites that adhere to your organization’s guidelines.
How to Create a Site Design from an existing site in SharePoint Online?
Before you start creating a site design from an existing site, ensure that you have the following prerequisites in place:
- SharePoint Online environment with the SharePoint Administrator permissions on the tenant
- An existing SharePoint site that will serve as the basis for your site design
- Updated SharePoint Online Management Shell
With the Get-SPOSiteScriptFromWeb cmdlet, we can create a site design from an existing site collection and then use the site design to create new instances of the site. The cmdlet is a new feature addition to SharePoint Online! It extracts the site schema from a given site and can be used to create copies of any existing site structure. Here are the basic syntax and examples:
Syntax:
Get-SPOSiteScriptFromWeb `
-WebUrl <Web-URL> `
-IncludeBranding `
-IncludeTheme `
-IncludeRegionalSettings `
-IncludeSiteExternalSharingCapability `
-IncludeLinksToExportedItems `
-IncludedLists ("<site-relative-URL-of>")
Example:
Get-SPOSiteScriptFromWeb -WebURL https://crescent.sharepoint.com/sites/marketing -IncludeBranding -IncludeTheme -IncludeRegionalSettings -IncludeLinksToExportedItems -IncludeSiteExternalSharingCapability -IncludedLists ("Lists/work","Shared%20Documents")
So, here, we include the site’s external sharing capability, site’s custom theme, navigation links, and regional settings with relevant switch parameters. We also specified particular lists to include in the site design template using an array for the List URL.
Create Site Design from an Existing site using PowerShell
Before using this cmdlet, make sure you have the updated SharePoint Online PowerShell module installed: How to Update SharePoint Online PowerShell Module?, This script creates a site design from an existing SharePoint site:
#Define Parameters
$AdminSiteUrl= "https://crescent-admin.sharepoint.com"
$SiteURL = "https://crescent.sharepoint.com"
#Connect to SharePoint Admin Center
Connect-SPOService -Url $AdminSiteUrl
#Get the site schema to a variable
$SiteSchema = Get-SPOSiteScriptFromWeb -WebURL $SiteURL -IncludeBranding -IncludeTheme -IncludeRegionalSettings -IncludeSiteExternalSharingCapability -IncludedLists ("Lists/Events","Shared%20Documents")
#Add site schema as Site Script
$SiteScript = Add-SPOSiteScript -Title "Crescent Site Template v1" -Content $SiteSchema
#Create a Site Design for Team Site template from site script output
$SiteDesign = Add-SPOSiteDesign -Title "Crescent Site Template v1" -WebTemplate 64 -SiteScripts $SiteScript.Id
This PowerShell script extracts the configuration of the site through a site schema and then uses that schema to create a Site Script and a Site Design. To get a list of web template IDs, refer: Get SharePoint Online Web Template IDs
Associate a site template to a hub site
You can associate a site design with a Hub site, so the design will automatically be applied to any site that joins this hub!
#Get the Hubsite
$HubSite = Get-SPOHubSite | Where {$_.Title -eq "Marketing"}
#Get the Site design
$Sitedesign = Get-SPOSiteDesign | where {$_.Title -eq "Crescent Projects V2"}
#Associate the Site design with the Hub
Set-SPOHubSite -Identity $hubsite -SiteDesignId $SiteDesign.Id
How to Create a New site based on the Site Design?
Once the site template is created, You can create a new site collection based on the site design you created:
- From the SharePoint Admin Center, click on the “Create” button under “Active Sites” >> Select the site type such as “Communication site”
- On the “Select a template” page, Click on the “From your organization” tab and select the site template you have created.
- Click on the “Use Template” button. Then, you can proceed with site creation by entering the site name, URL, and Administrator fields.
Apply site design to existing sites
You can also apply the site design to existing sites using the “Apply Site Template” link in the site settings menu of any modern site!
Pick the site template in the “From your organization” tab.
Here is my other post on: How to Create SharePoint Site Scripts and Site Designs.
PnP PowerShell to Create a Site Design from an Existing Site
Here is how to create a site design from an existing site using PnP PowerShell:
#Template site URL
$TemplateSiteURL = "https://salaudeen.sharepoint.com/sites/PMO"
#Connect to the site
Connect-PnPOnline -Url $TemplateSiteURL -Interactive
#Create a Site design from existing site
Get-PnPSiteScriptFromWeb -IncludeAllLists | Add-PnPSiteScript -Title "Crescent Projects Script V4" | Add-PnPSiteDesign -Title "Crescent Projects Sites V4" -WebTemplate CommunicationSite
Here, we have used the Get-PnPSiteScriptFromWeb cmdlet as the pipeline input for creating a new site design. More on managing site designs and site scripts with PnP PowerShell is here: https://learn.microsoft.com/en-us/sharepoint/dev/declarative-customization/site-design-pnppowershell
Best Practices for Site Design Creation
To make the most out of site designs in SharePoint Online, consider the following best practices:
- Plan your site designs carefully, considering the various site types and requirements within your organization.
- Use meaningful, descriptive names and descriptions for your site designs to make them easily identifiable and understandable for users.
- Regularly Update Your Site Designs: As your organization evolves, so should your site designs. Regular updates ensure they remain relevant and effective.
- Leverage SharePoint Look Book: Explore the SharePoint Look Book for inspiration and best practices in site design.
- Test Before Deployment: Always test your site designs in a controlled environment before rolling them out organization-wide.
Conclusion
Creating a site design from an existing site in SharePoint Online is a powerful way to streamline your site creation process, ensure consistency, and enforce governance policies across your SharePoint environment. By following the step-by-step guide and best practices outlined in this article, you’ll be well-equipped to harness the full potential of site designs and take your SharePoint site creation to the next level.
Remember, the key to successful site design implementation lies in careful planning, regular maintenance, and effective communication with your users. By staying proactive and continually refining your site designs, you’ll be able to create a SharePoint environment that is efficient, consistent, and optimized for your organization’s unique needs.
You can also create a site design from scratch from a JSON file: How to Create a Site Template in SharePoint Online?
Everything applies, no error messages received but nothing changes when I apply the new template – the site still looks like the default?
I have the same issue 🙁 @Saludeen Rajack a answer to this would be great 🙂
Hi Marcel,
Never got this working and haven’t found anyone who has!
In the end I had to create the site, set permissions and add the required web parts using PnP Powershell and PowerAutomate.
I see that the command Get-SPOSiteScriptFromWeb doesn’t treat nested libraries unless I add them to the array, is it true?
is there a way to take in care the nested libraries?
thanks a lot
I’m getting error as “Add-SPOSiteDesign : The remote server returned an error: (400) Bad Request.”
How do you remove existing Site Templates “From your organization”?
I am getting a file not found error
That’s because: I’ve included “Events” list as part of “IncludedLists” parameter. You may not have the “Events” list in your site! So remove that list from the parameter value.
I am not able to see the site design dropdown in my case . The script ran successfully. But I am not able to find it on SP Admin center or on Subsite creation.
Now, It’s moved under “Apply a Site Template” >> “From your organization” section of site collections.
Hello, this is fantastic. Can this work for a subsite?
No It Doesnt
Thanks for the update