Incorrect site url in Hub Site Navigation after Invoke-SPOSiteSwap

If you like to replace your SharePoint Online root site collection to different site collection, Microsoft has released Invoke-SPOSiteSwap -powershell command. This is handy, for example, when you are creating intranet by using modern SharePoint Communication Sites.

Invoke-SPOSiteSwap is pretty simple command. You just have to have Source Site Collection URL, Target Site Collection URL, and Archive URL. Source Site Collection will be archived and replaced by target site collection.

Problems after Invoke-SPOSiteSwap in Hub Site Navigation

Note!: If you are working with a Hub Site, you have to remove hub site associations, before you can run Invoke-SPOSiteSwap -command successfully.

I removed my intranet hub sites associations from the SharePoint Admin center.

Then I run the Invoke-SPOSiteSwap command (see code sample below) and every thing went well. Source Site collection was archived and target site collection was copied to the SharePoint Root Site.

Invoke-SPOSiteSwap -SourceUrl https://yourtenant.sharepoint.com/sites/IntranetHub -TargetUrl https:/
/yourtenant.sharepoint.com -ArchiveUrl https://yourtenant.sharepoint.com/sites/Archive

Then I created Root Hub Site once again and re-associated hub sites to the target site collection by using SharePoint Admin center.

Every thing seems to be ok, until I noticed, that url in the Hub Site Navigation was pointing to the previous url (/sites/IntranetHub). It didn’t pointed to the tenant root site collection (https://yourtenant.sharepoint.com) as it should be. I waited two days, but there was no change in the navigation url.

Then it tried to edit the Hub Site navigation link by using editing menu. Surprisingly, you can’t change the navigation root item link (in my case Intranet Hub) by using SharePoint navigation editing menu. You can only change the associated hub sites links via edit menu. See picture below.

Then I tried to edit navigation link by using Hub Site settings. Just to notice, that there is no settings to edit navigation link or url. You can just change the Hub site navigation logo and Hub site name via hub site settings. See picture below.

Solution: use powershell command Register-SPOHubSite

Then I decided to create Hub Sites Associations by using PowerShell.

First, I removed all hub site associations from the intranet by using Remove-SPOHubSiteAssociation -command.

PS C:\Windows\system32> Remove-SPOHubSiteAssociation https://yourtenant.sharepoint.com/sites/comms
PS C:\Windows\system32> Remove-SPOHubSiteAssociation https://yourtenant.sharepoint.com/sites/hr
PS C:\Windows\system32> Remove-SPOHubSiteAssociation https://yourtenant.sharepoint.com/sites/people
PS C:\Windows\system32> Remove-SPOHubSiteAssociation https://yourtenant.sharepoint.com/sites/it

Second, I unregistered root site collection to stop working as a Hub Site by using Unregister-SPOHubSite -command.

Unregister-SPOHubSite https://yourtenant.sharepoint.com

Third, I registered root site collection again to the Hub site by using Register-SPOHubSite -command.

PS C:\Windows\system32> Register-SPOHubSite https://yourtenant.sharepoint.com  -Principals $null

Then, I set the title and the description to the root hub site by using Set-SPOHubSite -command.

PS C:\Windows\system32> Set-SPOHubSite https://yourtenant.sharepoint.com/ -Title "Intranet Hub" -Description "Hub for the Intranet”

Last, I reassociated all previously associated hub sites to the root hub site collection by using the Add-SPOHubSiteAssociation -command.

PS C:\Windows\system32> Add-SPOHubSiteAssociation https://yourtenant.sharepoint.com/sites/comms -HubSite https://jhuovi.shar
epoint.com
PS C:\Windows\system32> Add-SPOHubSiteAssociation https://yourtenant.sharepoint.com/sites/hr -HubSite https://jhuovi.sharepo
int.com
PS C:\Windows\system32> Add-SPOHubSiteAssociation https://yourtenant.sharepoint.com/sites/people -HubSite https://jhuovi.sha
repoint.com
PS C:\Windows\system32> Add-SPOHubSiteAssociation https://yourtenant.sharepoint.com/sites/it -HubSite https://jhuovi.sharepo
int.com
PS C:\Windows\system32> Add-SPOHubSiteAssociation https://yourtenant.sharepoint.com/sites/teamsite -HubSite https://jhuovi.s
harepoint.com
PS C:\Windows\system32>

Finally, everything was correct in the Hub site navigation

That was the trick! PowerShell commands fixed the problems and I noticed that the hub site url was now correct in the hub site navigation. See picture below.

SharePoint roads are never boring, happy coding!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s