0

I've recently converted a 400 page classic wiki into modern pages on SPO, but I need them to all follow a template I've created.

Is there a way (in PnP Powershell) in the script I follow to convert the pages at the stage the page converts, to create the modern page with a specified template? or take the converted modern pages, then make copies of each one with a newly specified template?

I am following the script here: https://pnp.github.io/script-samples/modernize-bulk-publishing-pages/README.html?tabs=pnpps

I have searched everywhere and cannot find any examples of this, making a copy of a page with a new template... I don't want to have to change each page to match there are too many to do it manually :/

1 Answer 1

0

There is no such function to convert pages and apply template at the same time. You need to convert the pages to modern page. Then you can add template to pages by following script.

 # SET PAGE NAME
 $PageName = "hey.aspx"
    
 # RETRIEVE THE TEMPLATE 
 $NewsTemplate = Get-PnPClientSidePage "Templates/newstemplate.aspx"  
    
 # SAVE TEMPLATE AS NEW PAGE
 $NewsTemplate.Save($pageName);

===================================

If the answer is helpful, please click "√" on the left panel of the answer and kindly upvote it.

2
  • Thanks for your answer! this does work to create a page based on the template I wish to use, however, it is being used on migrated classic-> modern pages and it seems to delete all of the content, leaving the page template changed but the content missing.. any idea how to accomplish this without losing the content on the page? Jun 14, 2022 at 16:55
  • There seems no such function currently. Maybe you can try some third part tool to migrate your pages Jun 17, 2022 at 8:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.