Yes/No Column PnP PowerShell

Set Default Page Layout in Modern SharePoint with PnP PowerShell


In the world of SharePoint Online, managing page layouts is crucial for maintaining consistency and enhancing user experience. However, setting the default page layout in Modern SharePoint Online differs from the classic approach, requiring a nuanced understanding of the available tools and methods. In this blog post, we’ll explore how to set default page layout in Modern SharePoint using PnP PowerShell, specifically focusing on the challenges and solutions in Modern SharePoint environments.

Understanding the Challenge

Traditionally, setting the default page layout in SharePoint Online was straightforward, thanks to the Set-PnPDefaultPageLayout cmdlet in PnP PowerShell. However, as of the current scenario, this approach is tailored for publishing sites or classic sites, posing a dilemma for Modern SharePoint Online users.

It’s worth noting that while PnP PowerShell commands continue to evolve and adapt to the changing landscape of SharePoint Online, support for Modern SharePoint environments may vary with updates and releases. Therefore, it’s essential to stay informed about the latest developments and enhancements in PnP PowerShell to leverage its full potential in Modern SharePoint Online scenarios.


Before getting started with setting up the default page layout in Modern SharePoint Online using PnP PowerShell, ensure you have the following prerequisites in place:


In Modern SharePoint Online, setting the default page layout involves leveraging PnP PowerShell alongside other commands to manipulate site properties effectively. Below, we outline a step-by-step guide along with sample code to illustrate this process:

Step 1: Get the Page File

First, retrieve the desired page file using the Get-PnPPage cmdlet, specifying the identity of the custom page template.

$page = Get-PnPPage -Identity "Templates/CustomPageTemplate.aspx"
$pageFile = $page.GetPageFile()

Step 2: Update Site Property

Next, ensure that scripting capabilities are enabled on the site by temporarily setting NoScriptSite to false. This step is essential for modifying property bags.

Set-PnPSite -Identity -NoScriptSite $false

Step 3: Set Default Page Layout

Add the unique identifier of the custom page template to the site’s property bag using the Set-PnPPropertyBagValue cmdlet.

Set-PnPPropertyBagValue -Key "DefaultNewPageTemplateId" -Value $pageFile.UniqueId

Step 4: Finalize Configuration

Once the default page layout is set, revert the scripting capabilities to their original state by setting NoScriptSite to true.

Set-PnPSite -Identity -NoScriptSite $true


In conclusion, while the Set-PnPDefaultPageLayout cmdlet may not currently support Modern SharePoint Online, the landscape of SharePoint development is dynamic, with constant updates and improvements. As PnP PowerShell continues to evolve, there’s a possibility that future updates may extend support to Modern SharePoint environments, simplifying tasks such as Set default page layout in Modern SharePoint using PnP PowerShell. Therefore, staying engaged with the SharePoint community and keeping abreast of the latest developments in PnP PowerShell is crucial for maximizing productivity and efficiency in SharePoint Online environments.

Related Posts

Leave a Reply

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