How to: Swap your root/ main SharePoint modern site with another

The need to swap the site often comes when you’re upgrading your old SharePoint intranet (sometimes using Classic design) and ready to launch the new site. You want the new site to have the main URL of your SharePoint https://[tenant-name]
The old site then needs to be archived and not deleted.

In my example I have my new site under
and what I want is for the content of this site to be on my root site URL:

You don’t want to lose the content on either of the site, just want to swap the URL.

Luckily you can use the command below to do just this:

  1. Ensure that your new site is not a [hub site], and if it is, you need to temporarily unregister it as a hub site. Here is how to unregister a site from being a Hub Site

  2. Open SharePoint Online Management Shell as an administrator on your computer. Execute and enter your username and password to authenticate as admin:
    Connect-SPOService -Url https://[tenant-name]

  3. Run this as one command:
    Invoke-SPOSiteSwap -SourceUrl https://[tenant-name] -TargetUrl https://[tenant-name] -ArchiveUrl https://[tenant-name]

In here,
-SourceURL is your new intranet built-in SharePoint Modern
-TargetUrl is currently hosting your old intranet with all the sub-sites. Don’t worry, they will be preserved
-ArchiveUrl is where the content of the old intranet will be moved to.

  1. If you unregistered your new site as a hub site in step 1, you can now register the site as a hub site again.

SharePoint will even automatically redirect everyone who has bookmarked the old URL (https://[tenant-name] to now navigate to the new root URL.
No broken links!