From 2a3c57e5303a484de2b9214bef8f3b83b2d2393c Mon Sep 17 00:00:00 2001 From: James Addison Date: Sun, 1 Oct 2023 11:31:15 +0100 Subject: [PATCH 1/5] search.html: add 'noindex' directive to instruct web crawlers that content in search results should not be indexed --- sphinx/themes/basic/search.html | 1 + 1 file changed, 1 insertion(+) diff --git a/sphinx/themes/basic/search.html b/sphinx/themes/basic/search.html index f29d9db5089..1d9f58c2169 100644 --- a/sphinx/themes/basic/search.html +++ b/sphinx/themes/basic/search.html @@ -16,6 +16,7 @@ {%- endblock %} {% block extrahead %} + {{ super() }} {% endblock %} {% block body %} From 255b20d5d34caadc6bf1c26549613ecaf1bd629c Mon Sep 17 00:00:00 2001 From: James Addison Date: Sun, 1 Oct 2023 11:31:39 +0100 Subject: [PATCH 2/5] search.html: nitpick: apply consistent HTML element indenting --- sphinx/themes/basic/search.html | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sphinx/themes/basic/search.html b/sphinx/themes/basic/search.html index 1d9f58c2169..f2d6598983d 100644 --- a/sphinx/themes/basic/search.html +++ b/sphinx/themes/basic/search.html @@ -15,9 +15,9 @@ {%- endblock %} {% block extrahead %} - - - {{ super() }} + + + {{ super() }} {% endblock %} {% block body %}

{{ _('Search') }}

From 806044b1a27bc226b4bcaccf12368a3a227f9a7e Mon Sep 17 00:00:00 2001 From: James Addison Date: Sun, 1 Oct 2023 18:53:19 +0100 Subject: [PATCH 3/5] Add CHANGES entry for #11697 --- CHANGES.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGES.rst b/CHANGES.rst index d908c4b4587..00724ddbb48 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -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 basic theme: add 'noindex' meta robots tag. + Patch by James Addison. Testing ------- From 113e8b373be975cafb478b67a3debfe256535e27 Mon Sep 17 00:00:00 2001 From: James Addison Date: Mon, 2 Oct 2023 08:34:28 +0100 Subject: [PATCH 4/5] Add test coverage for meta robots 'noindex' element in HTML content build --- tests/test_build_html.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/test_build_html.py b/tests/test_build_html.py index 07f101d7aa0..dd934c321dd 100644 --- a/tests/test_build_html.py +++ b/tests/test_build_html.py @@ -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'}) From 0c4ea313d1b956e62d958e935164e27160660a83 Mon Sep 17 00:00:00 2001 From: Adam Turner <9087854+AA-Turner@users.noreply.github.com> Date: Tue, 3 Oct 2023 14:14:04 +0100 Subject: [PATCH 5/5] Update CHANGES.rst --- CHANGES.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGES.rst b/CHANGES.rst index 00724ddbb48..ca5fe1bc482 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -34,7 +34,7 @@ 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 basic theme: add 'noindex' meta robots tag. +* #11697: HTML Search: add 'noindex' meta robots tag. Patch by James Addison. Testing