SOLVED

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

%3CLINGO-SUB%20id%3D%22lingo-sub-631659%22%20slang%3D%22en-US%22%3EHow%20to%20display%20only%20subsites%20under%20a%20site%20collection%20using%20highlighted%20content%20web%20part%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-631659%22%20slang%3D%22en-US%22%3E%3CP%3EHello%20all%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EBefore%2C%20I've%20used%20the%20search%20results%20web%20part%20to%20display%20all%20my%20subsites%20under%20a%20site%20collection.%20Now%2C%20I'm%20in%20the%20process%20of%20%22modernizing%22%20all%20the%20sites%20and%20I%20like%20to%20display%20a%20list%20of%20all%20the%20sites%20under%20a%20site%20collection.%20How%20can%20I%20achieve%20that%20with%20a%20modern%20web%20part%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThanks%20in%20advance!%3C%2FP%3E%3CP%3E-Wagner%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-631659%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3ESharePoint%20Online%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-631731%22%20slang%3D%22en-US%22%3ERe%3A%20How%20to%20display%20only%20subsites%20under%20a%20site%20collection%20using%20highlighted%20content%20web%20part%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-631731%22%20slang%3D%22en-US%22%3EHi%20%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F149619%22%20target%3D%22_blank%22%3E%40Wagner%20Cox%3C%2FA%3E%2C%3CBR%20%2F%3E%3CBR%20%2F%3ESee%20article%3CBR%20%2F%3E%3CBR%20%2F%3E%3CA%20href%3D%22https%3A%2F%2Fsupport.office.com%2Fen-us%2Farticle%2Fuse-the-highlighted-content-web-part-e34199b0-ff1a-47fb-8f4d-dbcaed329efd%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Ehttps%3A%2F%2Fsupport.office.com%2Fen-us%2Farticle%2Fuse-the-highlighted-content-web-part-e34199b0-ff1a-47fb-8f4d-dbcaed329efd%3C%2FA%3E%3CBR%20%2F%3E%3CBR%20%2F%3EReferring%20specifically%20to%20filtering%20the%20sub%20sites%20you%20need%20to%20view.%3CBR%20%2F%3E%3CBR%20%2F%3EHope%20that%20answers%20your%20question!%20Let%20me%20know%20how%20it%20goes.%3CBR%20%2F%3E%3CBR%20%2F%3EBest%2C%20Chris%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-631974%22%20slang%3D%22en-US%22%3ERe%3A%20How%20to%20display%20only%20subsites%20under%20a%20site%20collection%20using%20highlighted%20content%20web%20part%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-631974%22%20slang%3D%22en-US%22%3EThere%20isn't%20a%20way%20to%20my%20knowledge%20to%20get%20subsites%2C%20all%20the%20modern%20web%20parts%20are%20built%20around%20top%20level%20site%20collections%20as%20subsites%20haven't%20been%20recommended%20to%20use%20in%20awhile%20on%20SharePoint%20online.%20%3CBR%20%2F%3E%3CBR%20%2F%3EYou'll%20have%20to%20look%20for%20a%20custom%20spfx%20extension%20to%20deploy%20(easy%20to%20do)%20to%20accomplish%20this.%20There%20is%20a%20content%20search%20web%20part%20clone%20that%20might%20fit%20the%20bill%20here%3A%20%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2FSharePoint%2Fsp-dev-fx-webparts%2Ftree%2Fmaster%2Fsamples%2Freact-content-query-webpart%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Ehttps%3A%2F%2Fgithub.com%2FSharePoint%2Fsp-dev-fx-webparts%2Ftree%2Fmaster%2Fsamples%2Freact-content-query-webpart%3C%2FA%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-632321%22%20slang%3D%22en-US%22%3ERe%3A%20How%20to%20display%20only%20subsites%20under%20a%20site%20collection%20using%20highlighted%20content%20web%20part%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-632321%22%20slang%3D%22en-US%22%3E%3CP%3EHi%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F149619%22%20target%3D%22_blank%22%3E%40Wagner%20Cox%3C%2FA%3E%26nbsp%3B%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EYou%20should%20be%20able%20to%20use%20the%20Highlighted%20content%20Web%20Part%20to%20achieve%20this%20using%20the%20following%20settings%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSTRONG%3EContent%3C%2FSTRONG%3E%3C%2FP%3E%3CP%3ESource%3A%20This%20site%20collection%3C%2FP%3E%3CP%3EType%3A%20All%3C%2FP%3E%3CP%3EDocument%20type%3A%20Any%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSTRONG%3EFilter%20and%20sort%3C%2FSTRONG%3E%3C%2FP%3E%3CP%3EFilter%3A%20Managed%20property%3C%2FP%3E%3CP%3EFind%20a%20managed%20property%3A%20content%3C%2FP%3E%3CP%3EManaged%20property%20name%3A%3C%2FP%3E%3CUL%3E%3CLI%3EContentClass%3C%2FLI%3E%3CLI%3EEquals%3C%2FLI%3E%3CLI%3ESTS_Web%3C%2FLI%3E%3C%2FUL%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ECheers%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EGrant.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-653270%22%20slang%3D%22en-US%22%3ERe%3A%20How%20to%20display%20only%20subsites%20under%20a%20site%20collection%20using%20highlighted%20content%20web%20part%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-653270%22%20slang%3D%22en-US%22%3E%3CP%3EThank%20you%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F283024%22%20target%3D%22_blank%22%3E%40gjen020%3C%2FA%3E!%20That%20did%20the%20trick.%20I%20appreciate%20it%20the%20help.%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E
Occasional Contributor

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

7 Replies
Hi @Wagner Cox,

See article

https://support.office.com/en-us/article/use-the-highlighted-content-web-part-e34199b0-ff1a-47fb-8f4...

Referring specifically to filtering the sub sites you need to view.

Hope that answers your question! Let me know how it goes.

Best, Chris
There isn't a way to my knowledge to get subsites, all the modern web parts are built around top level site collections as subsites haven't been recommended to use in awhile on SharePoint online.

You'll have to look for a custom spfx extension to deploy (easy to do) to accomplish this. There is a content search web part clone that might fit the bill here: https://github.com/SharePoint/sp-dev-fx-webparts/tree/master/samples/react-content-query-webpart


best response confirmed by Wagner Cox (Occasional Contributor)
Solution

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.

Thank you @gjen020! That did the trick. I appreciate it the help. 

@gjen020 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

@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.

@gjen020 Brilliant!  Worked like a charm.

 

Last thing - to sort by Site Name or Title?