Set a page template as default page template in SharePoint Online
SharePoint Online is a powerful collaboration and content management platform that allows organizations to create and manage sites for various purposes. One of the key features that enhances site design and improves user experience is the use of Page Templates. In this blog post, we will delve into what are page templates in SharePoint online and how to set a default page template for a SharePoint site.
What are Page Templates in SharePoint?
Page templates in SharePoint Online are pre-designed layouts or structures that provide a consistent and standardized format for creating site pages within a site. They serve as a starting point for designing and organizing content on SharePoint pages, ensuring a cohesive look and feel across the site.
Page templates can include a variety of elements such as placeholders for text, images, web parts, page sections, and more. By using page templates, users can quickly create new pages with a predefined structure and layout, saving time and effort while maintaining visual consistency.
Setting a Default Page Template for a SharePoint Site
When users try to create new site pages from SharePoint site home page, the default selected template in the Page Templates pane is Blank. If users don’t select a different template, the blank template will be used for their new page.
If you prefer to have another custom page template be the default selection for your SharePoint site while creating new site pages, follow one of the methods given below:
Using SharePoint User Interface
Follow below steps to set a default page template for your SharePoint online site from SharePoint UI:
1. Go to home page of your SharePoint online site.
2. Click on New from page command bar and select Page:

3. Click on vertical ellipses at the bottom right side of the template you want, and then select Set default selection:

4. Click OK from Changing default selection confirmation popup.
Note: When you change the default selection in the page templates pane, it will be changed for all users in the SharePoint site.
Using PnP PowerShell
You can use below PnP PowerShell script to set a page template as default page template for SharePoint online site:
# SharePoint online site URL
$siteUrl = Read-Host -Prompt "Enter your SharePoint site URL (e.g https://contoso.sharepoint.com/sites/work)"
# Connect to SharePoint online site
Connect-PnPOnline -Url $siteUrl -Interactive
# Get page template details and Unique ID
$page = Get-PnPFile -Url "/sites/work/SitePages/Templates/PlainHeaderNoComments.aspx" -AsListItem
# Set a page template as default page template for SharePoint online site
Set-PnPPropertyBagValue -Key DefaultNewPageTemplateId -Value $page["UniqueId"]
# Disconnect SharePoint online connection
Disconnect-PnPOnline
You may get error like below while executing above PnP PowerShell script if custom scripts are not enabled for your SharePoint site:
Set-PnPPropertyBagValue: Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED)) Site might have NoScript enabled, this prevents setting some property bag values.
In that case, you have to first enable the custom scripts for your SharePoint site by following: Allow use of custom scripts in SharePoint Online using PowerShell.
Using CLI for Microsoft 365
Use below CLI for Microsoft 365 script to set a page template as default page template for SharePoint online site:
# Get Credentials to connect
$m365Status = m365 status
if ($m365Status -match "Logged Out") {
m365 login
}
# SharePoint online site URL
$siteUrl = Read-Host -Prompt "Enter your SharePoint site URL (e.g https://contoso.sharepoint.com/sites/work)"
# Get page template details and Unique ID
$page = m365 spo file get --webUrl $siteUrl --url '/sites/work/SitePages/Templates/PlainHeaderNoComments.aspx' | ConvertFrom-Json
# Set a page template as default page template for SharePoint online site
m365 spo propertybag set --webUrl $siteUrl --key DefaultNewPageTemplateId --value $page.UniqueId
If custom scripts are not enabled for your SharePoint site, above CLI for Microsoft 365 script will throw error like:
Error: Site has NoScript enabled, and setting property bag values is not supported
In that case, you have to first enable the custom scripts for your SharePoint online site by following: Allow use of custom scripts in SharePoint Online using PowerShell.
Conclusion
Page templates in SharePoint online provide a valuable tool for enhancing site design and improving user experience. By setting a default page template, organizations can establish a consistent and standardized format for creating web pages within their SharePoint sites. This not only saves time but also ensures a cohesive and professional look across the site. By leveraging page templates, organizations can effectively showcase their content while maintaining their branding and style guidelines.
Learn more
- SharePoint Online: Create a blank page without header & title
- Create a SharePoint online site using Power Automate flow
- Delete custom site scripts in SharePoint online using PowerShell
- Set SharePoint site home page using PnP PowerShell and CLI for Microsoft 365
- Change SharePoint Online List URL using PnP PowerShell