Skip to content

Duplicate <script id="documentation_options"> with Sphinx 4 #1159

@andersk

Description

@andersk

Problem

Sphinx 4.0.0 changed the way the documentation_options script is inserted, such that we’re now inserting an extra copy of it. This results in invalid HTML (duplicate id).

Reproducible Project

This is reproducible with a totally empty project:

$ pip install Sphinx sphinx_rtd_theme
Collecting Sphinx
[…]
Successfully installed Jinja2-3.0.1 MarkupSafe-2.0.1 Pygments-2.9.0 Sphinx-4.0.2 alabaster-0.7.12 babel-2.9.1 certifi-2021.5.30 chardet-4.0.0 docutils-0.17.1 idna-2.10 imagesize-1.2.0 packaging-20.9 pyparsing-2.4.7 pytz-2021.1 requests-2.25.1 snowballstemmer-2.1.0 sphinx-rtd-theme-0.5.2 sphinxcontrib-applehelp-1.0.2 sphinxcontrib-devhelp-1.0.2 sphinxcontrib-htmlhelp-2.0.0 sphinxcontrib-jsmath-1.0.1 sphinxcontrib-qthelp-1.0.3 sphinxcontrib-serializinghtml-1.1.5 urllib3-1.26.5
$ mkdir docs
$ touch docs/index.rst
$ sphinx-build -C -D html_theme=sphinx_rtd_theme docs build
Running Sphinx v4.0.2
[…]
The HTML pages are in build.

Error Logs/Results

$ grep documentation_options build/index.html
      <script type="text/javascript" id="documentation_options" data-url_root="./" src="_static/documentation_options.js"></script>
        <script data-url_root="./" id="documentation_options" src="_static/documentation_options.js"></script>

Expected Results

Only one copy of <script id="documentation_options"> should be present.

Environment Info

  • Python Version: 3.8.9
  • Sphinx Version: 4.0.2
  • RTD Theme Version: 0.5.2

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions