Transform Classic SharePoint Pages To Modern Look And Feel

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.
 
Transform Classic SharePoint Pages to Modern Look and Feel 
 
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 SharePoint Pages to Modern Look and Feel 

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.
  1. # Connect to the classic site with pages to modernize  
  2. Connect-PnPOnline -Url https://contoso.sharepoint.com/sites/teamsite  
  3.  
  4. # Modernize page1.aspx and add the page keep/discard banner on the page  
  5. ConvertTo-PnPClientSidePage -Identity page1.aspx -AddPageAcceptBanner  
Transform Classic SharePoint Pages to Modern Look and Feel 
 
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.
Transform Classic SharePoint Pages to Modern Look and Feel 
Let us open the page and compare side by side.
 
Classic Page look and feel
 
Transform Classic SharePoint Pages to Modern Look and Feel 
The above classic web part page looks like this after it is transformed into the Modern client-side page.
 
Transform Classic SharePoint Pages to Modern Look and Feel 
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.
 
Transform Classic SharePoint Pages to Modern Look and Feel 
 
Follow the below steps if you do not see the banner web part on the Classic page.
  1. Download the banner web part solution (sharepointpnp-pagetransformation-client.sppkg) from the sp-dev-modernization repository here.
  2. Add it to your SharePoint tenant app catalog.
  3. Select “Make this solution available to all sites in the organization”.

    Transform Classic SharePoint Pages to Modern Look and Feel

  4. Click "Deploy".
Use the below code to transform all Classic pages into the Modern pages.
  1. # Connect to the web holding the pages to modernize  
  2. Connect-PnPOnline -Url https://contoso.sharepoint.com/sites/modernizationme  
  3.  
  4. # Get all the pages in the site pages library  
  5. $pages = Get-PnPListItem -List sitepages  
  6.  
  7. # Iterate over the pages  
  8. foreach($page in $pages)   
  9. {   
  10.     # Optionally filter the pages you want to modernize  
  11.     if ($page.FieldValues["FileLeafRef"].StartsWith(("t")))  
  12.     {  
  13.         # No need to convert modern pages again  
  14.         if ($page.FieldValues["ClientSideApplicationId"] -eq "b6917cb1-93a0-4b97-a84d-7cf49975d4ec" )   
  15.         {   
  16.             Write-Host `Page $page.FieldValues["FileLeafRef"is modern, no need to modernize it again`  
  17.         }   
  18.         else   
  19.         {   
  20.             # Create a modern version of this page  
  21.             Write-Host `Modernizing $page.FieldValues["FileLeafRef"]...`  
  22.             $modernPage = ConvertTo-PnPClientSidePage -Identity $page.FieldValues["FileLeafRef"] -Overwrite  
  23.             Write-Host "Done" -ForegroundColor Green  
  24.         }  
  25.     }    
  26. }  

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.