Skip to content

Commit

Permalink
Add 'noindex' meta robots tag to the search results page (#11700)
Browse files Browse the repository at this point in the history
  • Loading branch information
jayaddison authored Oct 3, 2023
1 parent 5d58624 commit 71d3eae
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
2 changes: 2 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ Bugs fixed
* #11483: singlehtml builder: Fix MathJax lazy loading when the index does not
contain any math equations.
Patch by Bénédikt Tran.
* #11697: HTML Search: add 'noindex' meta robots tag.
Patch by James Addison.

Testing
-------
Expand Down
5 changes: 3 additions & 2 deletions sphinx/themes/basic/search.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@
<script src="{{ pathto('_static/language_data.js', 1) }}"></script>
{%- endblock %}
{% block extrahead %}
<script src="{{ pathto('searchindex.js', 1) }}" defer></script>
{{ super() }}
<script src="{{ pathto('searchindex.js', 1) }}" defer></script>
<meta name="robots" content="noindex" />
{{ super() }}
{% endblock %}
{% block body %}
<h1 id="search-documentation">{{ _('Search') }}</h1>
Expand Down
3 changes: 3 additions & 0 deletions tests/test_build_html.py
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,9 @@ def test_html4_error(make_app, tmp_path):
(".//h1", "Generated section"),
(".//a[@href='_sources/otherext.foo.txt']", ''),
],
'search.html': [
(".//meta[@name='robots'][@content='noindex']", ''),
],
}))
@pytest.mark.sphinx('html', tags=['testtag'],
confoverrides={'html_context.hckey_co': 'hcval_co'})
Expand Down

0 comments on commit 71d3eae

Please sign in to comment.