Dedicated search page

Is there a way to have a dedicated page that shows the results with pagination and all?

For example, when you hit enter while searching for a term, it now takes you to the first result. I know you can disable this in the autocomplete.js options, but is there a way to redirect you to a page with all the results?


1 Like

This is not something we provide by default as one of the mail goal of docsearch is to be “plug and play”

That being said the index generated by our crawler can be use in a various way including building a dedicated search page.

It just requires a bit of custom code but it’s pretty straightforward.

I prototyped it a while ago with instantsearch.js (our library to build instant search pages).
You can have a look here:


Hi @maxime, sorry if this is outdated, but I just ran across your comment and JSfiddle as I’m trying to implement something similar (using my docsearch index for instantsearch.js). My problem is that I’m using Docusaurus, so there’s no easy way for me to add the template <script> tag. Is there another way to implement your solution? I tried this but it doesn’t work:

  const hitTemplate = function(hit) {

  return `
    <div class="ais-result">
      <div class="ais-lvl0">

      <div class="ais-lvl1">

          > {{{_highlightResult.hierarchy.lvl2.value}}}

          > {{{_highlightResult.hierarchy.lvl3.value}}}

          > {{{_highlightResult.hierarchy.lvl4.value}}}
      <div class="ais-content">

and then

      container: '#search-hits',
      templates: {
        empty: 'No results',
        item: hitTemplate