diff --git a/doc/sources/.templates/layout.html b/doc/sources/.templates/layout.html
index a87dc0bac..99b1f0f66 100644
--- a/doc/sources/.templates/layout.html
+++ b/doc/sources/.templates/layout.html
@@ -96,24 +96,32 @@
{%- if not embedded %}
-
-{%- block scripts %}
- {%- for scriptfile in script_files %}
-
- {%- endfor %}
-
-
-
-{%- endblock %}
+ {%- block scripts %}
+ {% if sphinx_version >= "1.8.0" %}
+
+ {%- for scriptfile in script_files %}
+ {{ js_tag(scriptfile) }}
+ {%- endfor %}
+ {% else %}
+
+ {%- for scriptfile in script_files %}
+
+ {%- endfor %}
+ {% endif %}
+
+
+
+ {%- endblock %}
{%- if use_opensearch %}