This post will walk thru a simple example of building a Project Hub by provisioning modern Project sites for an organization using the new SharePoint site design and site script capabilities. It’s important to standardize sites across your tenant, particularly in flat site architectures where there are lots of sites being provisioned. If you find yourself repeating the same configuration over-and-over again when provisioning sites, this is a good indication it should be automated as a site design. Follow along and I’ll show how to do just that for an organization’s Project sites!
For the non-developers out there… don’t let a bit of JSON and PowerShell scare you away. I want to demonstrate how easy and intuitive this was to do. With a bit of JSON knowledge and a few PowerShell commands, you can have a Site Design deployed to your tenant in a short period of time. (as long as your requirements aren’t too complex)
You can choose to “hand-roll” the JSON, as I’ve done here, or check out a great PnP solution, Site Designs Studio, contributed by Yannick Plenevaux to assist in creating/changing the site scripts and site designs: https://github.com/SharePoint/sp-dev-solutions/tree/master/solutions/SiteDesignsStudio
Note: for more advanced site designs including SharePoint Framework solutions, Azure functions and Microsoft Flow, check out a recent post by Bob German titled Building SharePoint Site Designs with Themes and Azure functions.
The steps in this post assume we have a Project Hub site already created. For this post, I’ve created a new modern Communication site and identified it as a Hub on the tenant.
[Update April 2021] You can now make a SharePoint site a Hub thru the UI of the SharePoint Admin Center.
I’ve updated the Hub navigation to include links to organizational project resources to demonstrate how navigation will be shared with any Project sites joined to the Hub. (Project Templates, Corporate Project Dashboard)
Following are the 4 high-level steps to create a custom Project Site design that will be automatically included in the Project Hub:
- Define resources and actions to be taken when a Project site is created
- Build the site script JSON file to do them using actions
- Add the site script and site design to the tenant via PowerShell
- Create a Project site with the design to test!
Step 1: Decide on Project Site Resources and Actions
- Project Document content type to include site columns:
- Project name: single line of text
- Document type: choice (Requirements, Design, TestPlan, Project Charter)
- Create new Project Documents library
- Add Project Document content type to the new library
- Remove Document content type from the new library
- Add Project Documents library to the navigation
- Remove Documents, Pages, and Site Contents from the navigation
- Add the Project site to the Project Hub
Step 2: Build JSON File
Using the Site design JSON schema reference, I built a JSON file with the actions to complete the project site resources. I used the following actions:
- createSiteColumn – Project name column
- createSiteColumnXml (for the choice column) – Document type column
- createContentType – Project Document content type
- addSiteColumn – add site columns to the Project Document content type
- createSPList – create Project Documents library
- addContentType – add Project Document content type to library
- removeContentType – remove Document content type from library
- addNavLink – add nav for Project Documents library
- removeNavLink – remove miscellaneous nav links
- joinHubSite – join Project Site to the Project Hub
Here is the JSON file with the above site actions: (if you don’t see the expanded source, click on the link)
I saved the file as C:\Scripts\ProjectSitescript.json
Step 3: Add Site Script and Site Design to the Tenant
This is done using PowerShell. First, you add the saved JSON file from above as a site script and then use it for your site design. I’m referencing the Team Site web template (64) in my Site Design since I want the Project Site to use the Team Site template:
Step 4: Create a Site with the Design
Ready to test! When I click Create site from the SharePoint app and select the Team Site tile, I’m now presented with 2 options on the design dropdown. It’s pulling the Title property from the Site Design I created, Project Site. I select it and enter a test name for my new Project site, Joanne’s Special Project:
and voila! The site is ready. I check the Project site’s navigation and the Project Documents library and they’re exactly as I’d specified in the JSON file. Since Joanne’s Special Project site has been joined to the Project Hub, I also see the navigation from the Hub:
[Update July 16, 2019] Now that Retention can be auto-applied based on a Content Type, we can now apply retention on all Project Documents across the Project Hub. Just add ContentType:’Project Document’ as a condition to apply it.
By automatically joining all Project sites to the Project Hub, they all share a common navigation, search is scoped to only the Project sites, and they share a common theme. Excellent!
Kudos to the team at Microsoft responsible for this provisioning mechanism. I’m really impressed at how well this worked and how quickly it came together. The hardest part for me was ensuring the JSON file was correctly formatted and that I had everything defined within it. I’ll definitely be building out site templates for tenants I work in to help with the structure and organization of SharePoint sites, particularly in the modern, flat site architecture world we all live in.
Thanks for reading.