Copying a page from one site to another in SharePoint

In this post we look at three different ways you can copy a page from one SharePoint site to another

In this post we look at three different ways you can copy a page from one SharePoint site to another.

Intro

The copy/ move features within SharePoint Online were introduced a few years ago, and although they are pretty good, aren’t without their limitations – something I wrote about in 2021. One such limitation is the inability to be able to copy or move site pages from one SharePoint site to another – a frequent request of users and of the SharePoint community to Microsoft, but so far nothing has been implemented.

I’m going to cover a few ways you can copy a site page from site to site, using a variety of different tools and products along the way.

#1 Create a flow in Power Automate

In this example we can use Power Automate to allow users to select the page they want to copy, input the site URL they want to copy to and let the flow do its magic!

  • Create a new flow in Power Automate > use the instant cloud flow option.
  • Create a for a selected file trigger > enter the site address and library name.

NOTE: In my example, just entering ‘Site Pages’ resulting in my flow not appearing in the Site Pages library. This seems to be an issue with the for a selected file trigger. In order to get it to show up, I had to use the library ID instead of the library name. To get the library ID:

  • Open the library settings > more library settings
  • Copy everything between List=&7B until %7D – this is the library ID
Copy the library ID which is the numbers between &7B and %7D
  • In the for a selected file trigger > add an input
  • Select text as the user input type > update the input name and input value placeholder text. This user input type will be used to allow users to enter the site URL they wish to copy their pages to.
Add a text user input type to allow users to input the destination site URL.
  • Add a get file properties action and configure with the following:
    • Enter the source site address of your site pages library
    • Enter either site pages, or the ID of your site pages library
    • Under ID > select ID from the for a selected file trigger
  • Add a copy file action and configure with the following:
    • Current site address: source site address of your site pages library
    • File to copy: Identifier from get file properties
    • Destination site address: destination site (or whatever you called your user input) from for a selected file
    • Destination folder: /SitePages
    • If another file is already there: copy with a new name (optional)

Three steps – that’s it! Now go ahead and test your flow by selecting a site page and copying it to a different site by running your flow.

#2 Use PnP PowerShell

Another way you are able to do this is with PowerShell, in this case I’ll defer to the brilliant SharePoint diary who has a great write up, including all cmdlets you need to copy a page from site to site, or copy all pages. I’ll include the relevant sample for my blog post, but full credit goes to SharePoint diary:

#Parameters
$SourceSiteURL = "https://crescent.sharepoint.com/sites/marketing"
$DestinationSiteURL = "https://crescent.sharepoint.com/sites/branding"
$PageName =  "About.aspx"
 
#Connect to Source Site
Connect-PnPOnline -Url $SourceSiteURL -Interactive
 
#Export the Source page
$TempFile = [System.IO.Path]::GetTempFileName()
Export-PnPPage -Force -Identity $PageName -Out $TempFile
 
#Import the page to the destination site
Connect-PnPOnline -Url $DestinationSiteURL -Interactive
Invoke-PnPSiteTemplate -Path $TempFile

Click here for the full artcle from SharePoint diary.

#3 Use 3rd party migration tools

The final option we have available to us is to utilize 3rd party migration tools to migrate pages between sites. For this example I’ll be using ShareGate, but there are other migration tools that are able to do the same thing:

  • Open ShareGate desktop > press copy.
  • Select copy content only.
  • Enter the URL of your source site > select the Site Pages library.
  • Do the same for the destination site.
  • Select the page from the source location you wish to copy
  • Under options, make the following configuration changes:
    • Check preserve authors and time stamps
    • Check permissions
    • Uncheck user alerts
    • Check web parts
    • Check version history
    • Uncheck flatten folder hierarchy
    • Check update links
    • Check check in as = published
  • Press start copy. Once completed, you should see two successful migration task items for your copied page:

Now you will find your newly copied page in the destination Site Pages library. In my experience of copying pages using ShareGate, images hosted within a CDN will still be present within your page, as will all the of text, layouts and any formatting. Images that are stored within different sites may error, as will document library/ list web parts that point to different sites also.


15 responses to “Copying a page from one site to another in SharePoint”

  1. Fantastic! Power Automate worked for me. Thank you very much!

  2. Hi Anthony, Thanks for the information, building the flow was pretty simple with your instructions. One question I’m struggling with… when I select a site page, then automate, then power automate, I don’t see the name of my flow. Only options are “Create a flow”, “See your flows”, and “Configure page approval flow”. Is there an additional step I need to take in order for the flow to become an available option?

    1. Hi, it could be that the permissions to your flow haven’t been set to allow others to run as/ be owners. More info here https://powerusers.microsoft.com/t5/Using-Flows/Instant-Flow-not-visible-in-the-associated-List/td-p/921731

      1. Hi Anthony, I was the flow owner so permissions were ok. It turned out the flow had to be built in my personal productivity environment since it uses a SharePoint integrated function, these only work in PP environment. I was originally creating in the staging environment since my intent was to move site pages from staging to production. Figured it was worth sharing in case anyone else incurs this issue. Thanks again for your help! Great job!

      2. Hi GM, thank you for following up on this. Out of interest, would environment variables in a solution overcome the integrated function issue? Best Anthony

  3. Hi, could you be specific about Library Settings please? Which Library where? (I got as far as realising that Power Automate refers to Power Automate the app/application/program, and not the Power Automate function within SharePoint, so I am making progress as a novice).

    >use the library ID instead of the library name. To get the library ID:

    Open the library settings > more library settings

    1. Hi, sure you just need to get to the library settings page by pressing more library settings. This then adds the ID of the library to the URL, which you can then grab

  4. Superb! I’ve never used Power Automate before but I followed the instructions to create a Flow and it worked perfectly. Thank you, Anthony!

    Fairly obvious, perhaps, but I note that the value for “Desination Site” to write into the query box when you’ve started the Flow is the landing page URL of the SharePoint Site (i.e. the /SitePages part of the URL where the .aspx file will end up was already written into the Flow settings)

    1. Hi Allan, thank for you the comment and the additional information – much appreciated!

  5. this is awesome, worked !

    1. Thank you! Glad it helped

  6. I used the Power Automate method that you suggested and it worked perfectly! I also understand a lot more about creating flows now, as this was my first one. Thanks so much!

    1. Thank you!

  7. Thank You for the detailed explanation while using SPPMT am getting error Enable custom script setting which is already on . Please advise

    1. Thanks for the comment. Without seeing the error specifically, I would suggest running the PowerShell cmdlet provided in the article below to enable custom scripting on ‘other’ sites aswell https://learn.microsoft.com/en-us/sharepoint/allow-or-prevent-custom-script

Leave a Reply

Recent posts

Discover more from SharePoint Stuff

Subscribe now to keep reading and get access to the full archive.

Continue reading