A lot of search queries use the contentclass:sts_site webtemplate:templatename construct to limit results only to root sites of a special site type (or sts_web for sub-sites). Living in SharePoint Online most sites will build of a blank or team site, and using the new provisioning engine from Office PnP, this becomes an issue for many. You can use the engine to save a template definition xml file, and create new ones off it, but how do you distinguish sites from one another?
One thought brought forward in the O365 Yammer network is to stamp each site created with a property in the web property bag, and have it indexed. All good, at least from a versioning and engine point of view for diffs etc., but from finding the sites it’s not really needed.
What I propose is to use a custom content type just for the home page of your site. A trick I learned from my good colleagues Tarjei and Ole Kristian at Puzzlepart, and one we use all the time.
This trick solves two problems:
- How to filter search for only sites of one particular type
- How to easily add and change metadata for a site
- Project Start Date
- Project End Date
- Project Leader
In the above image I inherit from Basic Page. You might want to inherit from Wiki Page or Web Part Page if that’s what you want to use as your home page.
Add the newly created content type to for example the Site Pages library, create a new page based on this content type, and assign it as the home page of your site.
To set custom meta data for your site, merely edit the properties of the home page.
The meta data entered for your home page will now be part of the sts_site/sts_web item which is indexed.
Fully security trimmed, automatically generated managed properties to use in your display templates just like any other list, and it’s super easy to change the metadata if needed. No custom UI, no fiddling with the property bag of the site for meta data or making the values searchable.
Want to search up all project sites? spcontenttype=projectsite will return them all.
And content types and pages are supported artifacts of the new provisioning engine.