didn't try it by myself but there is PnP Page Transformation tool which you may try. Check the following post: Can I convert a Publishing page to the modern experience. And also MS document Transform classic pages to modern pages.
SharePoint Pages Migration from SharePoint 2016 on-premises to SharePoint Online Modern Pages

Hello,
We are migrating SharePoint 2016 on-premises to SharePoint Online. SharePoint 2016 contains publishing pages and custom page layouts.
is there any way using PowerShell we can migrate and modernize the all the publishing pages and other classic pages to SharePoint Online modern pages?
Thanks,
Microsoft 365 and Office | SharePoint | Development
Microsoft 365 and Office | SharePoint | For business | Windows
6 answers
Sort by: Most helpful
-
-
Rajesh Lohar 21 Reputation points
2022-04-18T06:40:47.82+00:00 Thanks @sadomovalex . I tried it but getting error as "ConvertTo-PnPPage : could not find file PnP.Framework.resources"
I am not sure what is missing.
Thanks,
-
Tong Zhang_MSFT 9,251 Reputation points
2022-04-18T09:07:56.113+00:00 Hi anonymous user,
According to my research and testing, you can install SharePoint Migration Tool to do the migration. And you can use the following PowerShell script to migrate pages from SharePoint 2016 to SharePoint Online:$SourceSiteUrl = "http://sp/sites/xxx" $OnPremUserName = "xxx\xxxx" $OnPremPassword = ConvertTo-SecureString -String "<<PassWord>>" -AsPlainText -Force $SPCredential = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $OnPremUserName, $OnPremPassword $SourceListName = "xxx" #Define SharePoint target# $SPOUrl = "https://xxxxx.sharepoint.com/sites/xxxx" $UserName = "******@xxxxx.onmicrosoft.com" $PassWord = ConvertTo-SecureString -String "<<PassWord>>" -AsPlainText -Force $SPOCredential = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $UserName, $PassWord #Import SPMT Migration Module# Import-Module Microsoft.SharePoint.MigrationTool.PowerShell #Register the SPMT session with SharePoint credentials# Register-SPMTMigration -SPOCredential $SPOCredential -Force #Add two tasks into the session. One is SharePoint migration task, and another is File Share migration task.# Add-SPMTTask -SharePointSourceCredential $SPCredential -SharePointSourceSiteUrl $SourceSiteUrl -TargetSiteUrl $SPOUrl -MigrateAll #Start Migration in the console. # Start-SPMTMigration
My test results:
Use the following PowerShell script to convert all classic pages to modern pages:
#Set Parameters $SiteURL="https://xxxxx.sharepoint.com/sites/xxxxx" #Connect to Site Connect-PnPOnline $SiteURL -Credentials (Get-Credential) #-Interactive #Get All Pages from "Site Pager" Library $Pages = Get-PnPListItem -List SitePages -PageSize 500 ForEach($Page in $Pages) { #Get the page name $PageName = $Page.FieldValues.FileLeafRef Write-host "Converting Page:"$PageName #Check if the page is classic If($Page.FieldValues["ClientSideApplicationId"] -eq "b6917cb1-93a0-4b97-a84d-7cf49975d4ec") { Write-host "`tPage is already Modern:"$PageName -f Yellow } Else { #Conver the classic page to modern page ConvertTo-PnPPage -Identity $PageName -Overwrite -TakeSourcePageName -AddPageAcceptBanner Write-host "`tPage Converted to Modern!" -f Green } }
If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.
-
Rajesh Lohar 21 Reputation points
2022-04-18T12:34:29.337+00:00 Thanks for the above script.
Will it work with publishing site and publishing pages?Thanks,
-
Rajesh Lohar 21 Reputation points
2022-04-18T13:15:06.7+00:00 Hi,
I tried migration pages from SharePoint 2016 to SharePoint Online using SPMT Powershell, but it gave me an error as "The SharePoint version '0' is not supported". It seems it does not support SharePoint 2016.
Also I have few publishing sites and custom page layout. Please advise if those will be migrated and converted to Modern pages?
Thanks,