Setting up navigation based on search for Site collections

3 minute read

At the moment we are creating a portal based on host named site collections. The root site collection needs to display the sub site collections you have access to.

To give you a better understanding of what we created take a look at the following image:


Every site in the above image is a host named site collection. We are using separate site collections to be able to move sites between databases because the sites them selves will contain a large amount of data.

For the creation of the sub site collection we have created a custom provisioning method. How to do this provisioning can be read in my other article:

But now we had the challenge to display all the sites the current user has access to on the root site.

When we had setup the environment with the host named site collection it was time to create the representation of the sites on the root site (http://root).

First of all we started by adding the “Content Search” web part to the page that can be found in the “Content Rollup” category.


This web part will display several results already based on a empty search query. By editing the web part you will be able to define your own query.


Select the “Change Query” button to start defining your own query. Right away click on the “Switch to Advanced Mode” to start writing your own query. In the advanced window you will have a textbox to define a custom query.


Take a look at the following query we defined:

contentclass:STS_Site Path:{Site.Url}* Site<>{Site.Url}

The explanation of the query is the following:

  • contentclass:STS_Site : This will return every object within SharePoint that is of the type STS_Site. STS_Site stands for Site Collection. You also have STS_Web that stands for Web Site.
  • Path:{Site.Url}* : This will return only the sites that start with the current URL or have the current URL in the path variable. This means you will also retrieve the current site as a result.
  • Site<>{Site.Url} : This will return everything but the current site.

So by using this query you will retrieve every site collection under (URLwise) the current site collection that you have access to (Because search results are security trimmed).

For displaying these sites you can use several out of the box managed properties. Save the query by clicking “OK”. Then in the edit properties window extend the “Property Mappings” section.


In the screen shot above you can see several properties of a site that then result in the following:


The title’s links to the correct site. The logo’s of the sites are displayed when they have a custom logo attached. The description is also displayed and because we do not have any owners specified in this demo you can not see the result of this.

Within a custom portal you also have the option of using property bag properties within your search queries or your results, how this can be accomplished can be read here: