Site Directory
Search and browse SharePoint sites using SharePoint Search with typeahead and favourites.
Get Site Directory Working in 3 Steps
Prerequisites
- Bonzai 2 package installed on your site
- SharePoint sites indexed by search
Add the web part
Edit your page and add "Bonzai Site Directory" from the Bonzai category.
Configure display options
Open the property pane and configure which site details to display (owner, date, description).
Enable features
Toggle on favourites and typeahead search, then publish your page.
Search-based discovery
contentclass:STS_Site) to automatically discover and display sites. No manual list configuration is required — sites are indexed by SharePoint automatically, and users only see sites they have access to.Smart search with automatic fallback
bnz will match ModernTeamSite01bnz). SharePoint KQL only supports suffix wildcards natively, so this fallback closes the gap for middle-of-word searches.When to Use This Web Part
Use this when you need to...
- Create a searchable site catalog
- Allow users to find SharePoint sites
- Enable site bookmarking (favourites)
- Browse all sites in the organization
Best page locations
- Intranet homepage — site search widget
- Navigation hub — all sites directory
- People & Directory page — site listings
Consider alternatives when...
- • Quick links to specific pages — use Advanced Links
- • Document search — use Document Portal
- • Curated list of sites — use Favourite Sites
Related web parts:
Common Configurations
Full Site Directory
Complete site search with all details
| title | All Sites |
| itemsPerPage | 12 |
| showFavourites | On |
| showCreatedDate | On |
| showSiteOwner | On |
| showDescription | On |
| enableTypeahead | On |
Compact Site Search
Minimal site finder for homepage
| title | Find a Site |
| itemsPerPage | 8 |
| showFavourites | On |
| showCreatedDate | Off |
| showSiteOwner | Off |
| showDescription | Off |
| enableTypeahead | On |
Favourites Focus
Quick access to bookmarked sites
| title | My Sites |
| showFavourites | On |
| showDescription | On |
| additionalLinkText | View All Sites |
| additionalLinkUrl | /sites/intranet/sites |
Best Practices
Enable typeahead for large organizations
Use Result Source ID for scoping
Hub sites are auto-highlighted
IsHubSitemanaged property from the search index.Favorites are stored locally
bonzai_site_directory_favorites), providing quick access without server configuration. Note that favorites do not sync across browsers or devices.Reference
How It Works
Site Directory uses the SharePoint Search REST API (/_api/search/query) with a contentclass:STS_Site filter to discover and display sites. Unlike web parts that require a manually maintained list, Site Directory automatically finds all sites that users have access to. You can optionally scope results using a custom Result Source GUID.
Search strategy (two-phase):
- Server-side KQL — Tries multiple patterns in order: free-text with
contentclass:STS_Site, a suffix wildcard (query* contentclass:STS_Site), and aTitle:query*prefix. SharePoint KQL only supports suffix wildcards natively. - Client-side fallback — If server-side returns zero results, fetches up to 500 sites and filters locally on title, URL, and description. This enables middle-of-word matches (e.g.
bnz→ModernTeamSite01bnz).
The service tries several selectProperties combinations from most-detailed (Title, Path, Description, Author, Created, LastModifiedTime, SiteId, WebId, WebTemplate, IsHubSite, HubSiteId) down to minimal (Title, Path), retrying with a less-ambitious set if the tenant rejects any managed property. It also falls back from the configured Result Source ID to the default source if the custom source returns an error.
URL filtering: Non-site URLs are automatically excluded from results (.aspx, .docx, .xlsx, .pdf, .pptx,/_layouts/, /forms/, /siteassets/, /sitepages/,/lists/) so only true site roots are displayed.
Site card rendering: Each card shows an auto-selected Fluent UI icon based on the site template (Team/Group → Group, Communication → CommunicationDetails, Hub → HubSite, otherwise SharepointLogo). Hub sites additionally get a "Hub Site" badge. Clicking anywhere on a card (except the favorite button) opens the site in a new tab.
Debouncing: Search queries are debounced by 400ms after typing stops; typeahead suggestions by 200ms and require at least 2 characters. Stale suggestion responses are discarded so only the latest keystroke wins.
Favorites storage: Bookmarked sites are persisted in browser local storage under the key bonzai_site_directory_favorites as an array of{ url, title, addedDate } entries. They are per-user and per-browser.
Property Pane Configuration
Title Settings
| Property | Type | Description |
|---|---|---|
title | Text | Web part title (default: "Site Directory"). When blank, the title/header row is hidden entirely (including the additional link). |
titleIconOption | Dropdown | Title icon mode (default: custom / "Select Icon"). Options: "Select Icon" or "None". Setting to "None" removes the title icon. |
titleIconName | Text | Fluent UI icon name (default: SharepointLogo). Only displayed in the property pane when Title Icon is set to "Select Icon". |
titleIconUrl | Text | Custom icon URL. When set, overrides titleIconName. Only effective when Title Icon is not "None". |
Data Source
| Property | Type | Description |
|---|---|---|
resultSourceId | Text | Optional Result Source GUID to scope site search results. Must be a valid GUID — invalid values are silently ignored and the default source is used instead. |
itemsPerPage | Slider (4-50) | Number of sites to display per page (step: 4, default: 12) |
Display Options
| Property | Type | Description |
|---|---|---|
showFavourites | Toggle | Show the favorite star button on each site card (default: On). Users can click to bookmark sites — favorites are stored in browser local storage. |
showCreatedDate | Toggle | Show site created date on each card (default: On) |
showSiteOwner | Toggle | Show site owner (Author) on each card (default: On) |
showDescription | Toggle | Show site description on each card (default: On) |
enableTypeahead | Toggle | Enable search suggestions dropdown while typing (default: On). Shown in the property pane as "Enable Search Suggestions". Suggestions appear after 2+ characters and are debounced by 200ms. |
Additional Link
| Property | Type | Description |
|---|---|---|
additionalLinkText | Text | Text for a link shown in the header next to the title (e.g., "View All Sites"). Only rendered when both this text and additionalLinkUrl are set (and the web part title is non-blank, since the header row is otherwise hidden). |
additionalLinkUrl | Text | URL for the header link. Opens in a new tab. |
Features Checklist
- ✅ SharePoint Search-based site discovery (
contentclass:STS_Site) - ✅ Two-phase search: server-side KQL + client-side fallback for partial matches
- ✅ Typeahead search suggestions (debounced 200ms, min 2 chars)
- ✅ Suggestion click navigates directly to the site in a new tab
- ✅ Debounced search input (400ms after typing stops)
- ✅ Site favorites (browser local storage, per-user / per-browser)
- ✅ Pagination with ellipsis for large result sets
- ✅ Show/hide site metadata (owner, created date, description)
- ✅ Auto-selected site icons based on template (Team / Communication / Hub / SharePoint)
- ✅ Automatic "Hub Site" badge on hub sites
- ✅ Non-site URL filtering (excludes .aspx, documents, lists, layouts)
- ✅ Click card to open site in a new tab
- ✅ Custom Result Source filtering (validates GUID format)
- ✅ Graceful degradation of
selectPropertiesacross tenants - ✅ Configurable title, title icon (Fluent UI or custom URL), and header link
- ✅ Responsive design with Fluent UI components