Tuesday, May 11, 2021

SharePoint Modern Page: Site Collections Directory

Adding a site collection directory to a SharePoint classic page was easy. However, with the new modern pages in SharePoint, it has become more challenging. A quick, easy way I have found to accomplish this need is to use the Highlighted Content web part and a custom query. See below for details.

1. Add the Highlighted Content web part on the page where you want the site collection directory.

2. Edit the Highlighted Content web part, select 'Custom query', select 'All sites' for the Source, and then add the following custom query in the 'Query text (KQL)' box: Path:"https://tenant.sharepoint.com/sites/*" contentclass:STS_Site. See screenshot below for an example. To sort the results on the page, you are given the option to use a managed property to sort on. As you can see in the screenshot below, I searched for the term "string", and ultimately selected the 'RefinableString00" managed property, which sorted my site collections by site name.



3. Republish the page.