Office 365 – SharePoint Online – Creating hub sites
Today in this article we will discuss the options to create / register hub site in SharePoint online.
There are multiple ways to create the Hub site in SharePoint Online.
- From SharePoint Admin center
- Using PowerShell
- Using CSOM
From SharePoint Admin center
- Create the site collection either Communication site or Modern Team Site
- Navigate to SharePoint Admin Center – https://<mytnant>-admin.sharepoint.com/
- Select the site which you created and register as Hub site as in my following test tenant –
Figure 1:Office 365-SharePointOnline – Registering hub site
- From the top navigation click on arrow near Hub icon
Figure 2: Office 365-SharePointOnline – Hub site icon in top navigation
Figure 3: Office 365-SharePointOnline – “Register as hub site” option in top navigation in SharePoint Admin Center
- Select option “Register as hub site” option, once we clicked on this option, “Register as hub site” info bar will appear where please specify the “Display name” for the hub site and second option is optional. No need to specify there anything so that any user can associate their site with hub site
- We are ready, site will be Hub site and we can associate our other sites to this hub site.
Figure 4: Office 365-SharePointOnline – Register Info bar – Put the hub site display name
Using PowerShell: Following are the Steps / PowerShell commands to register and un-register the hub site
- Open the “SharePoint Online Management Shell” – Run as Administrator
- Connect to Office 365 using SharePoint admin URL as –
Figure 5: Office 365-SharePointOnline – Connecting to SharePoint admin using PowerShell – Credential Prompt
- Connect-SPOService -Url https://<my tenant>-admin.sharepoint.com/
- Prompt will appear for credentials as shown in below figure. Kindly please enter the credentials and connect.
- Register the given site as hub site using below PowerShell CMDLET
Register-SPOHubSite -Site <Site URL> – Registers given site as hub siteWe can unregister the registered hub site using below PowerShell CMDLET
Unregister-SPOHubSite –Identity <Site URL> – Unregisters given hub site. Site becomes normal site
- Create context using SharePoint admin site URL as
ClientContext tenantContext = new ClientContext("SharePoint Admin Site URL"); string Password = "PASSWORD”; string UserName = "USERNAME”; SecureString passWord = new SecureString(); foreach (char c in Password.ToCharArray()) passWord.AppendChar(c); clientContext.Credentials = new SharePointOnlineCredentials(UserName, passWord);
- Once we have ClientContext for SharePoint Admin site, we need tenant Tenant class object as
Tenant tenant = new Tenant(tenantContext);
- Using Tenant class object method called “RegisterHubSite” we need to register our site as hub site as
HubSiteProperties hubSiteProperties = tenant.RegisterHubSite(<SITE URL REGISTER HUB>); tenantContext.ExecuteQuery();
Thanks for reading 🙂
Keep reading, share your thoughts, experiences. Feel free to contact us to discuss more.
If you have any suggestion / feedback / doubt, you are most welcome.
Stay tuned on Knowledge-Junction, will come up with more such articles.