Skip to content

Commit 71d3eae

Browse files
authored
Add 'noindex' meta robots tag to the search results page (#11700)
1 parent 5d58624 commit 71d3eae

File tree

3 files changed

+8
-2
lines changed

3 files changed

+8
-2
lines changed

CHANGES.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ Bugs fixed
3434
* #11483: singlehtml builder: Fix MathJax lazy loading when the index does not
3535
contain any math equations.
3636
Patch by Bénédikt Tran.
37+
* #11697: HTML Search: add 'noindex' meta robots tag.
38+
Patch by James Addison.
3739

3840
Testing
3941
-------

sphinx/themes/basic/search.html

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,9 @@
1515
<script src="{{ pathto('_static/language_data.js', 1) }}"></script>
1616
{%- endblock %}
1717
{% block extrahead %}
18-
<script src="{{ pathto('searchindex.js', 1) }}" defer></script>
19-
{{ super() }}
18+
<script src="{{ pathto('searchindex.js', 1) }}" defer></script>
19+
<meta name="robots" content="noindex" />
20+
{{ super() }}
2021
{% endblock %}
2122
{% block body %}
2223
<h1 id="search-documentation">{{ _('Search') }}</h1>

tests/test_build_html.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -399,6 +399,9 @@ def test_html4_error(make_app, tmp_path):
399399
(".//h1", "Generated section"),
400400
(".//a[@href='_sources/otherext.foo.txt']", ''),
401401
],
402+
'search.html': [
403+
(".//meta[@name='robots'][@content='noindex']", ''),
404+
],
402405
}))
403406
@pytest.mark.sphinx('html', tags=['testtag'],
404407
confoverrides={'html_context.hckey_co': 'hcval_co'})

0 commit comments

Comments
 (0)