Overview
We have been using Classic SharePoint for many years. The Classic SharePoint offers nice wiki and web part pages to represent our information. Microsoft is rolling new updates to SharePoint Online on a frequent basis. At this time, we are living in two worlds of SharePoint - Classic SharePoint and Modern SharePoint. We are developing newer sites with Modern SharePoint and maintaining our old Classic SharePoint sites. It is not an easy task to convert all our Classic SharePoint sites to Modern sites. It needs to undergo a massive thought process.
The good news is Office PnP has come with an approach to help migrate our classic SharePoint pages to new modern look and feel.
In this article, we will explore how we can transform our classic SharePoint pages to the new modern look and feel.
Classic Pages vs Modern Pages
Classic Pages
Classic SharePoint offered Wiki pages and web part pages. They had a predefined placeholder to add our content to SharePoint. In a few situations, we had to adjust with a close matching layout of the page.
Modern Pages
Modern pages, on the other hand, offer a very dynamic layout. We can add as many sections as we need to align our content nicely.
Transform Classic Pages to Modern Pages
So far, we have developed a huge number of classic SharePoint sites. Can we get all those to Modern easily? The answer is Yes! We can perform an in-place upgrade using OfficeDev PnP solution. Modernizing the site involves the below steps.
- Maximize the use of the modern list and library experience
- Connect your site to Office 365 group
- Transform your wiki and web part pages to modern pages
- Rebuild your classic publishing portals to modern portals
Modernize the page
Page modernization is done by,
- Transforming classic wiki or web part page to modern client-side page.
- Page structure (e.g. header with 2 columns) is kept, wiki HTML is transformed into HTML that works on modern pages.
- Web parts on the page are replaced with modern 1st party web parts
The modern page is generated as a preview. The old page is kept as it is.
Modernize pages using PnP PowerShell
Install PnP PowerShell
On Windows PowerShell, use below commands.
SharePoint Online | Install-Module SharePointPnPPowerShellOnline |
SharePoint 2016 | Install-Module SharePointPnPPowerShell2016 |
SharePoint 2013 | Install-Module SharePointPnPPowerShell2013 |
If needed, install PowerShellGet from
here.
Use the below PowerShell code to transform the page into Modern.
- # Connect to the classic site with pages to modernize
- Connect-PnPOnline -Url https:
-
- # Modernize page1.aspx and add the page keep/discard banner on the page
- ConvertTo-PnPClientSidePage -Identity page1.aspx -AddPageAcceptBanner
Once the page is transformed, navigate to the Site Pages library. You will see Migrated_Home.aspx is created as a transformed modern version of the classic page.
Let us open the page and compare side by side.
Classic Page look and feel
The above classic web part page looks like this after it is transformed into the Modern client-side page.
There are a few things to notice -
- Web parts on the Classic page are replaced with modern 1st party web parts.
- Web parts not supported in the Modern SharePoint are not migrated.
Configure Banner
A banner like below will be shown on the classic page.
Follow the below steps if you do not see the banner web part on the Classic page.
- Download the banner web part solution (sharepointpnp-pagetransformation-client.sppkg) from the sp-dev-modernization repository here.
- Add it to your SharePoint tenant app catalog.
- Select “Make this solution available to all sites in the organization”.
- Click "Deploy".
Use the below code to transform all Classic pages into the Modern pages.
- # Connect to the web holding the pages to modernize
- Connect-PnPOnline -Url https:
-
- # Get all the pages in the site pages library
- $pages = Get-PnPListItem -List sitepages
-
- # Iterate over the pages
- foreach($page in $pages)
- {
- # Optionally filter the pages you want to modernize
- if ($page.FieldValues["FileLeafRef"].StartsWith(("t")))
- {
- # No need to convert modern pages again
- if ($page.FieldValues["ClientSideApplicationId"] -eq "b6917cb1-93a0-4b97-a84d-7cf49975d4ec" )
- {
- Write-Host `Page $page.FieldValues["FileLeafRef"] is modern, no need to modernize it again`
- }
- else
- {
- # Create a modern version of this page
- Write-Host `Modernizing $page.FieldValues["FileLeafRef"]...`
- $modernPage = ConvertTo-PnPClientSidePage -Identity $page.FieldValues["FileLeafRef"] -Overwrite
- Write-Host "Done" -ForegroundColor Green
- }
- }
- }
Summary
Transforming Classic SharePoint sites to Modern can be made easy with OfficeDev PnP offerings. However, keep in mind that all functionality will not be migrated as is to the Modern. A few functionalities might need to be rewritten using SharePoint Framework.