Skip to content

Commit ca9b658

Browse files
authored
Sitemap: don't include hidden versions (#11675)
Closes #11584
1 parent d0baa8e commit ca9b658

File tree

3 files changed

+25
-2
lines changed

3 files changed

+25
-2
lines changed

docs/user/reference/sitemaps.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ It contains information such as:
1717
* What translations are available for a page.
1818

1919
Read the Docs automatically generates a ``sitemap.xml`` for your project,
20-
by default the sitemap includes each version of your documentation and when it was last updated,
20+
the sitemap includes :ref:`public and not hidden versions <versions:Version states>` of your documentation and when it were last updated,
2121
sorted by version number.
2222

2323
This allows search engines to prioritize results based on the version number,

readthedocs/proxito/tests/test_full.py

+23-1
Original file line numberDiff line numberDiff line change
@@ -1554,6 +1554,17 @@ def test_sitemap_xml(self):
15541554
active=True,
15551555
type=EXTERNAL,
15561556
)
1557+
1558+
hidden_version = fixture.get(
1559+
Version,
1560+
identifier="hidden-version",
1561+
verbose_name="hidden-version",
1562+
slug="hidden-version",
1563+
privacy_level=constants.PUBLIC,
1564+
project=self.project,
1565+
active=True,
1566+
hidden=True,
1567+
)
15571568
# This also creates a Version `latest` Automatically for this project
15581569
translation = fixture.get(
15591570
Project,
@@ -1580,7 +1591,8 @@ def test_sitemap_xml(self):
15801591
self.assertEqual(response.status_code, 200)
15811592
self.assertEqual(response["Content-Type"], "application/xml")
15821593
for version in self.project.versions(manager=INTERNAL).filter(
1583-
privacy_level=constants.PUBLIC
1594+
privacy_level=constants.PUBLIC,
1595+
hidden=False,
15841596
):
15851597
self.assertContains(
15861598
response,
@@ -1598,6 +1610,16 @@ def test_sitemap_xml(self):
15981610
lang_slug=self.project.language,
15991611
),
16001612
)
1613+
1614+
# Hidden version should not appear here
1615+
self.assertNotContains(
1616+
response,
1617+
self.project.get_docs_url(
1618+
version_slug=hidden_version.slug,
1619+
lang_slug=self.project.language,
1620+
),
1621+
)
1622+
16011623
# The `translation` project doesn't have a version named `not-translated-version`
16021624
# so, the sitemap should not have a doc url for
16031625
# `not-translated-version` with `translation-es` language.

readthedocs/proxito/views/serve.py

+1
Original file line numberDiff line numberDiff line change
@@ -859,6 +859,7 @@ def changefreqs_generator():
859859
public_versions = Version.internal.public(
860860
project=project,
861861
only_active=True,
862+
include_hidden=False,
862863
)
863864
if not public_versions.exists():
864865
raise Http404()

0 commit comments

Comments
 (0)