Last week Microsoft started releasing hub sites for Office 365. Hub sites are a long awaited feature in the new Modern Office 365 experience. The introduction of Communication sites and Office 365 Groups sites has brought about a new flat architecture for building sites within SharePoint. While sub sites are still available, it is now becoming common practice to build new sites as separate site collections (Groups & Communication sites). However, when you build sites without a hierarchy, it's often difficult to understand which sites may be connected or even how the sites are connected. Hub sites will fix this issue by allowing admins to create a "hub" or a collection of sites under a single global navigation with some very cool content roll-up features. To learn more about hub sites click here.
Creating a hub site
If you get a chance to play around with hub sites, you'll notice that it requires a few PowerShell commands to enable them in your environment. Using the SharePoint Online Management Shell, you can register a hub site from an existing Communication or Group site. You can also add a hub site association using a PowerShell command (connecting a site to an existing hub). However, I'm going to show you how to auto associate sites with your new hub site using Site Designs and Site Scripts in Office 365.
First thing you need to do is make sure hub sites are enabled in the tenant. Using SharePoint Online Management Shell, execute:
Get-SPOHubsite
If you receive no errors, good news, you have the hub site feature released into your tenant. The next thing you need to do is register a site in your tenant to be a hub site. For this exercise, I have created a new site called "Intranet Demo". In order to register the site as a hub site, I can execute the following command.
Register-SPOHubsite https://mysite.sharepoint.com/sites/IntranetDemo
Next I will set some properties of the Intranet Demo site within the tenancy using Set-SPOHubSite.
Set-SPOHubSite https://mysite.sharepoint.com/sites/IntranetDemo -Title
"Intranet Hub" -Description "Hub for Intranet"
Now if I navigate to my site, I'll see a new global navigation header in the top of my hub site!
Once this hub site is created, I need to get the ID of the hub by calling Get-SPOHubsite and it should return the ID of my new hub site. I'll be using this ID later in my site script.
Get-SPOHubsite
Site Designs & Site Scripts
Before we get to far ahead of ourselves, it's important to know what a Site Design and a Site Script is. In Modern Office 365, Site Designs & Site Scripts are a method of creating templates for your Office 365 Group and Communication Sites. These are templates that show up in the "SharePoint Home" page in your Office 365 environment. We won't go too in-depth on creating them, but if you'd like more info about creating them, follow my previous post here.
A site script is a JSON file that we can create in order to describe actions that will be initiated when creating a new modern site in Office 365. One of the actions we have available to us is "joinHubSite". The verb takes one parameter "hubSiteId", which is the ID we grabbed a little earlier. This action, when used in a Site Script will automatically add the newly created site into an existing hub site!
{
"$schema": "schema.json",
"actions": [
{
"verb": "applyTheme",
"themeName": "Custom Black"
},
{
"verb": "joinHubSite",
"hubSiteId": "e9ec1fb4-d316-4e96-bd8a-96d76ca26a5f"
}
],
"bindata": { },
"version": 1
}
Using this JSON file and PowerShell, I'll create a Site Design named "Group Site for Intranet Hub" to use with Office 365 Groups (WebTemplate 64). Using the following commands, I will grab the JSON file and add the site design to my Office365 environment. (Notice Id comes from the result of "Get-Content")
#Add SPOSitescript to Office 365
Get-Content 'C:\Users\Demo\Site Designs\SiteScript.json'-Raw | Add-SPOSiteScript -Title "Beau Intranet Hub"
Id : 5f1b26ae-59c4-4b05-9def-2d91a5a9e041
Title : Beau Intranet Hub
Description :
Content :
Version : 0
#Add Site Design to SharePoint.aspx
Add-SPOSiteDesign -Title "Group Site for Intranet Hub" -WebTemplate "64" -SiteScripts "5f1b26ae-59c4-4b05-9def-2d91a5a9e041" -Description "Creates a site in the Intranet Hub"-PreviewImageUrl "https://mysite.sharepoint.com/SiteAssets/logo.jpeg" -PreviewImageAltText "site preview"
Now lets see what the result of these commands are. If I navigate to my SharePoint home page (_layouts/15/sharepoint.aspx), and create a new site, I should see a new Site Design called "Group Site for Intranet Hub".
I am going to select "Group Site for Intranet Hub" and create a test site and select next. The Office 365 group will start to provision itself, and you'll notice the Site Script is executing and adding the site to our new hub site.
Success! The Site Script I just created before using the joinHubSite action, has now automatically associated the new site with our hub! When I click "View updated site", i can now see the new global navigation bar in the top of my site which was created & inherited from the hub site.
I hope you found this post helpful as you begin to roll out Hub sites in Office 365. It's important to also know that you can only have 50 hub sites in Office 365. I haven't been told why this limitation exists, but it's something you should be aware as you start planning the information architecture for your new modern environment.
Share