Forum Discussion

Wagner Cox's avatar
Wagner Cox
Copper Contributor
May 21, 2019
Solved

How to display only subsites under a site collection using highlighted content web part?

Hello all,

 

Before, I've used the search results web part to display all my subsites under a site collection. Now, I'm in the process of "modernizing" all the sites and I like to display a list of all the sites under a site collection. How can I achieve that with a modern web part?

 

Thanks in advance!

-Wagner

  • Hi Wagner Cox ,

     

    You should be able to use the Highlighted content Web Part to achieve this using the following settings:

     

    Content

    Source: This site collection

    Type: All

    Document type: Any

     

    Filter and sort

    Filter: Managed property

    Find a managed property: content

    Managed property name:

    • ContentClass
    • Equals
    • STS_Web

     

    Cheers,

     

    Grant.

6 Replies

  • Hi Wagner Cox ,

     

    You should be able to use the Highlighted content Web Part to achieve this using the following settings:

     

    Content

    Source: This site collection

    Type: All

    Document type: Any

     

    Filter and sort

    Filter: Managed property

    Find a managed property: content

    Managed property name:

    • ContentClass
    • Equals
    • STS_Web

     

    Cheers,

     

    Grant.

    • LeeCharlebois's avatar
      LeeCharlebois
      Copper Contributor

      grant_jenkins This is great!

       

      Now, what if I wanted to do the same *from* a subsite, to only show subsite of the subsite?  When I do this from a subsite in my site collection, it of course list all subsites from the site collection down.  I tried changed the Source to This Site, to no avail - that only list the site the Web Part was on.

       

      Thanks,

      Lee

      • grant_jenkins's avatar
        grant_jenkins
        Iron Contributor

        LeeCharlebois 

         

        You can try the following

         

        Set your source to This site collection then instead of Filter use a Custom query and enter the following:

         

         

        ContentClass:"STS_Web" AND Path:"https://tenant.sharepoint.com/sites/sitecollection/subsite" AND -Title:"Title of subsite"

         

         

        ContentClass:"STS_Web"

         

        will only look at webs

         

        Path:"https://tenant.sharepoint.com/sites/sitecollection/subsite"

         

        will ensure it only looks at the current site plus subsites within it. You just need to put your tenant, your site collection and your subsite you want to search under.

         

        -Title:"Title of subsite"

         

        is a quick way to hide the current site from showing up if you only want to show the subsites beneath it. Notice that it has a hyphen before Title which means exclude. Just have to be careful that no subsites contain the same title. A better option is using SPWebUrl, but it's not mapped as a managed property by default so would require some work to do that.

Resources