diff --git a/Doc/tools/templates/layout.html b/Doc/tools/templates/layout.html
index 56023ebf962703..1cb0200822d9fe 100644
--- a/Doc/tools/templates/layout.html
+++ b/Doc/tools/templates/layout.html
@@ -26,11 +26,11 @@
{% endblock %}
{% block extrahead %}
- {% if builder == "html" and enable_analytics %}
+ {% if builder == "html" %}
+ {% if enable_analytics %}
- {% endif %}
-
- {% if builder != "htmlhelp" %}
+ {% endif %}
+
{% if pagename == 'whatsnew/changelog' and not embedded %}
{% endif %}
{% endif %}