PnP Provisioning engine provides a great functionality that allows to create Client Side Pages (modern pages) in PnP Templates. It supports storing in the XML structure the configured page containing web parts and assigned metadata.
The example presented below creates a page containing a two columns with web parts: Text and People.
However, there is a challenge to use this approach when working wish SharePoint 2019 as the Client Side Pages unfortunately are not supported. It can be checked in the implementation of the ClientSidePages handler – the code is not available in on premises build: GitHub: ClientSidePages handler
Recently, I had a task to automate upload of few pages to SharePoint 2019 environment. In case I was not able to use PnP templates – I have decided to use Add-PnPFile:
Add-PnPFile -Path <> -Folder “SitePages”
Below, I present the content of the ClientSidePage that can be uploaded to SitePages library. The page contains 2 webparts – Text and Twitter.
In the content, you can also find the example – how to assign the metadata directly in the file.
I hope the ClientSidePages handler will be supported in SharePoint on premises environment soon, but you can always use the presented approach as a workaround.