Search code examples
pythonfull-text-searchpython-sphinxread-the-docs

"Searching..." takes forever on readthedocs when the phrase is not present on the page


When I search for a phrase which is not present on the readthedocs page, I get the message:

"Searching...", which will take forever. On the contrary, when I search for some known phrase, I get the results within a second.

I have looked into page's console:

The resource from “https://xxxxxx.readthedocs.io/en/latest/_static/css/yy.css” was blocked due to MIME type (“text/html”) mismatch (X-Content-Type-Options: nosniff). Read the Docs search failed. Falling back to Sphinx search.

I have tried:

  1. [conf.py] I have line:

    html_css_files = [
        "css/yy.css",
    ]
    

so I added:

app.add_css_file(html_css_files) in def setup(app):

but this caused build error in readthedocs

  1. I have added in conf.py:

    notfound_urls_prefix = "/projects/xxxxxx/en/latest/"
    

but this also didn't help.

Have you encountered something similar? If so, how have you solved the problem?


Solution

  • In the end, the root-cause was somewhere else. When I looked into raw output on rtd, I found out that sphinx_rtd_theme was installed with 0.4.3, which is not the latest. The latest is 0.5.2. So I pinned the latest version in my docs/requiremets.txt. This fixed the searching problem.