How to Configure PnP Search for a Single SharePoint Site
Question details
The user needs to configure PnP Modern Search to return results exclusively from one specific SharePoint site, restrict the results to document files only, and display no results when the search box is left empty.
- Product
- SharePoint Online
- Device & OS
- not provided
- Scenario
- Customizing a modern SharePoint portal page to improve targeted document discovery using the PnP Modern Search web parts.
- Observed behavior
- Looking for the correct query template syntax and web part configurations to restrict the search scope and handle empty query states properly.
Ensure you have Site Owner or Site Collection Administrator permissions and that the PnP Modern Search web parts are already deployed and added to your modern SharePoint page.
Modify the Search Query Template
Apply a specific search query template within the web part properties to restrict results to your target site and document types.
By combining the search term variable with KQL (Keyword Query Language) property restrictions, you can force the web part to strictly return documents from a designated path.
Navigate to your SharePoint site, click on 'Edit' in the top right corner, and select the PnP Search Results Web Part to open its property pane.
Go to the first page of the web part configuration settings and locate the 'Query template' text field.
Input the following query string: {searchTerms} IsDocument:1 Path:"https://yourtenant.sharepoint.com/sites/yoursite*" (replace the URL with your actual tenant and site path).
Scroll through the settings pane to locate the toggle option that controls empty search behavior, and set it to not execute the query or hide results when the search input is empty.
Close the property pane and click 'Republish' to save your new search configuration.

Consult Developer Forums for Version-Specific Issues
Because PnP Modern Search is a custom community-driven solution, complex token behaviors or bugs may require expert developer support.
Edit Your SharePoint Documents Seamlessly with WPS Office
While SharePoint helps you organize and find files online, you need a robust editor for your local workflow. WPS Office is a free, lightweight suite that seamlessly handles Microsoft Office formats, allowing you to open, edit, and save your downloaded SharePoint documents with zero hassle.
- 1. Download the software: Visit the official WPS Office website to download the free installation package for your operating system.
- 2. Install WPS Office: Run the downloaded installer and follow the on-screen prompts to easily install the suite.
- 3. Open and edit files: Double-click any downloaded SharePoint document to open and seamlessly edit it within WPS Office.

Frequently Asked Questions
Why does my PnP search box return all results when empty?
By default, search components may execute a wildcard query when no text is entered. You must explicitly toggle the setting within the PnP Search Results web part configuration to 'Hide results when query is empty' or prevent the search from executing.
How do I ensure only PDF or Word files appear in my SharePoint search?
You can modify your search query template by adding file type restrictions. Combine your query with commands like FileType:pdf OR FileType:docx alongside IsDocument:1 to limit the output to those specific formats.
Can I configure PnP Search to look across multiple specific SharePoint sites?
Yes. You can expand the query path restriction to include multiple distinct sites by using the OR operator in your KQL statement, such as: {searchTerms} IsDocument:1 (Path:"https://tenant.sharepoint.com/sites/site1*" OR Path:"https://tenant.sharepoint.com/sites/site2*").




