Sometimes I get requirements when projects require a full width layout pages in Team Sites or would like to create a page which is System maintained, so users cannot edit those pages. In this blog, we will look at some of these options and how easy it is to set them up using PnP PowerShell
Set Full Width Layout pages using PnP PowerShell
By default, any new page that is created in Team site gets a left-hand navigation (Article Layout) when created through UI. At present, it is not possible to create a full width page using the UI. But we could do the same using PnP PowerShell or using an Azure Function.
In this blog, we will look at the PnP PowerShell way of creating it. We can also do that using an Azure Function by using the steps stated in this blog here.
For starting with PnP PowerShell, check the post here.
After connecting to the site, we can run the below PowerShell to create a page with Full width layout. We could also set it as Home Page when creating it.
Add-PnPClientSidePage -Name "Test.aspx" -LayoutType Home -PromoteAs HomePage
To change/set the page type of existing page, we can use the below script
Set-PnPClientSidePage -Identity "" -LayoutType Home -PromoteAs HomePage
Some of the other layout types are Article and SingleWebPartAppPage. Article is the default choice for Team Sites and have left hand navigation.
Create a Single Web Part Page
This option is beneficial when you would need a page where you don’t want users to add/update the webparts and are ready to set it programmatically. As it is evident, this choice is not available using the UI. The created page doesn’t have a command bar and is not editable from the UI. Hence the best part is that users cannot modify them. However, since there is no UI all the changes have been done using PowerShell. Also, the property options must be set using Json Properties using PropertiesJson.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
|Connect-PnPOnline –Url "https://sharepoint.com"|
|## Add Page using PnP PowerShell|
|$page = Add-PnPClientSidePage –Name "TestAppPart.aspx" –LayoutType SingleWebPartAppPage|
|## Add a section the Page|
|Add-PnPClientSidePageSection –Page $page –SectionTemplate OneColumnFullWidth|
|## Add a Client Side Web Part|
|Add-PnPClientSideWebPart –Page $page –DefaultWebPartType SiteActivity –Section 0 –Column 0|
So there you go, this is how we could create full width pages in Modern Team Sites and manage Modern Site Pages using PnP PowerShell