Skip to content

How to copy a modern SharePoint page

Have you ever had a situation where you have needed to copy a Modern SharePoint Online page from one site to another? Have you tried to click through the UI, only to realize that the built in copy/move function only works within the same site collection? For most of us, the same site collection also equals the same site so this won't work for our needs.

You can use the classic interface but this doesn't always seem to work for me.

You can use PowerShell, but:

  1. PnP PowerShell is not for the everyday SharePoint user
  2. PnP PowerShell isn't an official SharePoint product

However, while working on a project a client had asked us for an easy option for them to be able to do it without our help, as they wanted to make many adjustments. So, since this is gaining popularity on the Feedback Portal as a feature request that doesn't seem to be available, we put our thinking caps on and decided to try something.

Power Automate

A SharePoint page is, at its core, simply a file and Power Automate has a built-in function for copying files between SharePoint sites if you have ownership and/or full control over both. I believe it'll work if you only have access to view the source page as long as you still have full control over the destination - we didn't have a use case where that'd be the state of access, but give it a try! (Also, please be sure to vote on the feature request on the Feedback Portal - Microsoft does often take trending requests seriously.)

The flow is in four simple steps:

  1. Manual trigger - with inputs for the SourceSiteURL, PageName, DestinationSiteURL and a FailAction.1-manually trigger flow - Ryley Bauer

  2. Declare an Integer variable for the FailAction
    2-initialize fail action - Ryley Bauer

  3. Switch - translate the dropdown value into a number based on the input from the manual trigger3-switch - Ryley Bauer

  4. Copy file
    4-copy file - Ryley Bauer
    • Set source: SourceURL
    • Set file:  "/SitePages/PAGENAME"
    • Destination: DestinationURL
    • Destination Folder: /SitePages
    • If another file is already there: FailAction Number

That's the whole flow in four simple steps!

Once you have created and used the above flow, there are a few more ways that this flow can be changed or enhanced for your own use:

  • Add a condition to check if the user added the ".aspx" to the end of the page name and fix it if they didn't by appending “.aspx” to the variable using the Append to string variable step
  • Choose a FailAction for them, like copy with a new name
  • Use the Send an email step to send a confirmation email once complete
  • Use the Send an HTTP request to SharePoint step to add the page to site navigation

5-enhance flow - Ryley Bauer

Have you ever encountered a task that seemed easy, but turned out to be a missing feature,  function, or too technical to implement? While copying a page on SharePoint seems like a simple operation, Microsoft has not provided an easy way to move pages from one site to another. If you’d rather not learn PnP PowerShell, Power Automate is an incredibly powerful - yet simple - tool that can handle all sorts of automation requirements. You can use it for basic workflows such as this that simply copy a file, or design complex workflows to automate an entire business process, such as employee onboarding. 

If you need to automate a simple or complex process, but don’t know where to start, DevFacto is here to guide you on your journey to automation. Schedule a consult today to learn more about how we can help you automate your business in ways humans will love to use! Let us put the “auto” in automation so that you and your team can focus on what matters most!

 


 

About the author

Ryley Bauer is a Business Process Automation Consultant based in Calgary, Alberta. He has a background in automation, business analysis, and infrastructure support in a variety of industries. In his free time he tinkers with electronics, builds LEGO, plays guitar and drums, and doesn't tell anyone he secretly spends most of his time snuggling with his 3 cats. Connect with him on LinkedIn!

About the artist

Nikki is....Nikki of DKB is a multidisciplinary artist with work bridging mediums ranging from textiles to acrylics and everything imaginable in between. Her textile creations can be seen at www.darkknits.ca.

She writes “This piece was inspired by the article's aptness in solving the puzzles SharePoint often presents its users by offering tools not typically considered.”