top of page
  • Writer's pictureKasper Larsen

PnP Modern search: Set refiners in the URL

The PnP Modern Search Filter web part supports deep URL linking, so if you provide the correct URL both the Search text and selected filters can be activated once the page loads:

However, getting the correct URL can be tricky. The recommended approach is to set the search text and the relevant Filters and then grab the browser URL. It will look like this:


The components are: the URL to the page + the q section + the f section.

The q section is just the text to be applied in the Search Box.

The f section is the Filter settings. It looks pretty messy, but this PowerShell snippet will clean it up:

$url = Read-Host "Enter URL"

$pageURL = $url.Substring(0, $url.IndexOf("?"))

$filterURL = $url.Substring($url.IndexOf("?")+1)

$filterURL = $filterURL.Replace("%5B", "[")

$filterURL = $filterURL.Replace("%7B", "{")

$filterURL = $filterURL.Replace("%22", '"')

$filterURL = $filterURL.Replace("%3A", ":")

$filterURL = $filterURL.Replace("%2C", ",")

$filterURL = $filterURL.Replace("%5D", "]")

$filterURL = $filterURL.Replace("%7D", "}")

$filterURL = $filterURL.Replace("%C7%82%C7%82", "ǂǂ")

$newUrl = $pageURL + "?" + $filterURL


And once cleaned up it looks like this:


The value tag above is the Filter Token, and you will be able to find those using the SP Search Query Tool.

70 views0 comments

Recent Posts

See All


bottom of page