How to migrate content with PnP Provisioning Engine
The philosophy behind the PnP Provisioning Engine is changing, and it will start saving the content of the SharePoint sites if you explicitly request it.
Until now the provisioning engine was just getting the site structure, and the home page. To include content on it, you had to find workarounds to do it.
A year ago, I wrote an article with a workaround to include all the pages from a site in a template, it basically extracted the template multiple times (one for each page) and then combined everything in a single file.
With the latest release of the provisioning engine this workaround is no longer needed, and the pages are all added to the template at once. Lists items and documents are not yet supported but they will be also included in the upcoming releases.
This is a great change to the provisioning engine and finally it provides an easy way to migrate content from a site collection to another site collection.
How to Save a template with multiple pages
The example in this article was made using PnP PowerShell, to achieve the same result make sure you are using at least the June 2019 version.
To save a template with all the pages you will need to use the parameter -IncludeAllClientSidePages and it will extract all the pages in the Site Pages library including the page templates inside the template folder.
Connect-PnPOnline -url https://contoso.sharepoint.com #The handlers parameter is optional, it’s used here to make the extraction faster Get-PnPProvisioningTemplate -out template.xml -Handlers PageContents -IncludeAllClientSidePages
To apply the template back to another site you just need to run the Apply-PnPProvisioningTemplate cmdlet
Connect-PnPOnline -url https://contoso.sharepoint.com/sites/anothersite Apply-PnPProvisioningTemplate -path template.xml
If you are building and testing your pages on a dev environment this is an easy way to move all the pages to the production environment. If you will use this to migrate content, you will have to ensure that the resources referenced in the pages are available on the production site also.
Erwin van Hunen did a detailed explanation of this feature on the latest community call, you can watch it on the video below.