In this blog, we are going to see how to create a new modern Site Page in SharePoint site using PnP PowerShell.
Add-PnPClientSidePage command from PnP PowerShell will do the creation of a new modern page in SharePoint site.
Create Article layout modern page
The below PowerShell command is used to create a modern article page in a SharePoint site.
- PS:> $cred = Get-Credential
- PS:> Connect-PnPOnline -Url https://<tenant>.sharepoint.com/sites/dev -Credential $cred
- PS:> Add-PnPClientSidePage -Name “Article Page”
The page URL will be https://<tenant>.sharepoint.com/sites/dev/sitepages/article page.aspx
Output By default, Add-PnPClientSidePage creates an Article layout type. To create the Home layout type, we have to pass the Home as a LayoutType parameter.
We can also use the below command to create the same page without providing a –Name parameter
By default, Add-PnPClientSidePage creates an Article layout type. To create Home layout type, we have to pass the Home as a LayoutType parameter.
We can also use the below command to create the same page without providing the –Name parameter.
- Add-PnPClientSidePage “Article Page”
Create Home Layout Modern Page
The below PowerShell command used to create a home layout modern page in SharePoint Site Pages library.
- PS:> $cred = Get-Credential
- PS:> Connect-PnPOnline -Url https://<tenant>.sharepoint.com/sites/dev -Credential $cred
- PS:> Add-PnPClientSidePage -Name “Home Page” -LayoutType Home
The Page URL will look like: https://<tenant>.sharepoint.com/sites/dev/sitepages/home page.aspx
Output