Duplicate results in DocSearch with a Bootstrap-based static site

I am getting started with DocSearch and while it works, I get double results:

  • App ID: BH4D9OD16A
  • Setup (to make it easier for others to apply to their problem)
    • Static Github site user.github.io (edit: it’s a made up link, no need to click, sorry for the confusion)
    • DocSarch content is at user.github.io/docs/
    • DocSearch configuration:
  "selectors": {
    "lvl0": {
      "selector": "",
      "global": true,
      "default_value": "Documentation"
    "lvl1": "main h1",
    "lvl2": "main h2",
    "lvl3": "main h3",
    "lvl4": "main h4",
    "lvl5": "main h5",
    "text": "main p, main li"

This is how it looks like:


It appears (I’m not good at JS/CSS, obviously, otherwise I wouldn’t be asking :-D) the reason might be that my static docs pages (Bootstrap) have section ToCs

a) content I want to find is always “main” content (main class="..."), but
b) sometimes main content also has a page ToC (div class="toctree-wrapper compound") with ToC items that seem to correspond to main li
c) in worst cases there’s 3 results (e.g. page.html, its page ToC (in main), and the first in-page ToC entry itself as page.html#sec1)

I guess I should try to exclude main li (at least that) from my DocSearch config ("text": "main p, main li").

Any other ideas from Bootstrap or related experiences?

You can remove some content from the page using selectors_exclude .

To remove the ToC for instance:

  "selectors_exclude": [".toctree-wrapper"]

Also, I couldn’t help but notice in your screenshot that your implementation is surprisingly unstyled.
You can use DocSearch’s default implementation using https://docsearch.algolia.com/docs/dropdown .
If you are not looking for something too custom, it might fit your use-case.

1 Like

Thank you!

:laughing: very true! +1 for diplomatic skills.

And that’s after I applied CSS suggestions from the docs (it was worse before - in addition to the problem you see, the drop-down modal was also transparent :-D) . I deployed only yesterday, so I’m still working through various small issues.

I’ll try the suggestion later this week and report back for the community.

1 Like