pnp / modernization

All modernization tooling and guidance
http://aka.ms/sppnp-modernize
MIT License
157 stars 86 forks source link

[BUG] PnP Page transformation URL mapping issue #583

Closed PrasadMadhavan closed 3 years ago

PrasadMadhavan commented 3 years ago

Problem Area

[ ] Page Transformation: Error during the use of page transformation from PnP PowerShell

Expected or Desired Behavior

I am running PnP Powershell Version 1.3.0

I am running ConvertTo-PnPPage command to transform classic to modern pages.

The classic page is at the tenant root site collection as shown below. The page gets transformed, but ends up with a number of broken urls as explained below.

Sample Source URL: https://xxxx.sharepoint.com/aboutus/pages/major-projects.aspx

Note: Please note "aboutus" is a subsite under the root site collection https://xxxx.sharepoint.com

Sample Target URL: https://xxxx.sharepoint.com/sites/modernuat/aboutus/pages/major-projects.aspx

The links on the source page has urls embedded via content editor web part or summary links web parts. A sample source page url is given below. https://xxxx.sharepoint.com/aboutus/pages/communications.aspx

When I run the transformation command below, the above url gets re written as

https://xxxx.sharepoint.com/sites/modernuat/sites/modernuat/aboutus/sitepages/communications.aspx

Please note the links are incorrect. Ideally it should have been https://xxxx.sharepoint.com/sites/modernuat/aboutus/sitepages/communications.aspx

I tried to use a number of combinations of custom URL mapping csv, but it didnt work. A few options tried are listed below.

https://xxxx.sharepoint.com/AboutUs/Pages/communications.aspx,/AboutUs/SitePages/communications.aspx /AboutUs/Pages/communications.aspx,/AboutUs/SitePages/communications.aspx

Observed Behaviour

The embedded urls on the page is not mapped properly as shown below. https://xxxx.sharepoint.com/sites/modernuat/sites/modernuat/aboutus/sitepages/communications.aspx Please note the links are incorrect.

I wonder if this issue happens specifically because I am trying to copy from a root site collection.

Steps to Reproduce

ConvertTo-PnPPage -Identity "communications.aspx" -PublishingPage -TargetWebUrl https://xxxx.sharepoint.com/sites/modernuat/aboutus -OverWrite -PageLayoutMapping "C:\Dev\HE\Scripts\AboutUsProdMappingwithlayout.xml" -UrlMappingFile "C:\Dev\HE\Scripts\CustomURLMapping.csv"

I also tried -SkipDefaultUrlRewriting and -SkipUrlRewriting as well.

PrasadMadhavan commented 3 years ago

I guess I found my way by doing the following.

  1. Updated the mapping with relative urls /AboutUs/Pages,/sites/modernuat/AboutUs/SitePages
  2. Added -ClearCache to the command
  3. Added -SkipDefaultUrlRewriting to skip the default mappings.

I will close this case now.