diff --git a/docs/user/reference/sitemaps.rst b/docs/user/reference/sitemaps.rst index 67178599e9d..d3144448721 100644 --- a/docs/user/reference/sitemaps.rst +++ b/docs/user/reference/sitemaps.rst @@ -17,7 +17,7 @@ It contains information such as: * What translations are available for a page. Read the Docs automatically generates a ``sitemap.xml`` for your project, -by default the sitemap includes each version of your documentation and when it was last updated, +the sitemap includes :ref:`public and not hidden versions ` of your documentation and when it were last updated, sorted by version number. This allows search engines to prioritize results based on the version number, diff --git a/readthedocs/proxito/tests/test_full.py b/readthedocs/proxito/tests/test_full.py index d78a66b2087..eb9877f48a3 100644 --- a/readthedocs/proxito/tests/test_full.py +++ b/readthedocs/proxito/tests/test_full.py @@ -1554,6 +1554,17 @@ def test_sitemap_xml(self): active=True, type=EXTERNAL, ) + + hidden_version = fixture.get( + Version, + identifier="hidden-version", + verbose_name="hidden-version", + slug="hidden-version", + privacy_level=constants.PUBLIC, + project=self.project, + active=True, + hidden=True, + ) # This also creates a Version `latest` Automatically for this project translation = fixture.get( Project, @@ -1580,7 +1591,8 @@ def test_sitemap_xml(self): self.assertEqual(response.status_code, 200) self.assertEqual(response["Content-Type"], "application/xml") for version in self.project.versions(manager=INTERNAL).filter( - privacy_level=constants.PUBLIC + privacy_level=constants.PUBLIC, + hidden=False, ): self.assertContains( response, @@ -1598,6 +1610,16 @@ def test_sitemap_xml(self): lang_slug=self.project.language, ), ) + + # Hidden version should not appear here + self.assertNotContains( + response, + self.project.get_docs_url( + version_slug=hidden_version.slug, + lang_slug=self.project.language, + ), + ) + # The `translation` project doesn't have a version named `not-translated-version` # so, the sitemap should not have a doc url for # `not-translated-version` with `translation-es` language. diff --git a/readthedocs/proxito/views/serve.py b/readthedocs/proxito/views/serve.py index c2cae91a1fc..90a9b5f81f3 100644 --- a/readthedocs/proxito/views/serve.py +++ b/readthedocs/proxito/views/serve.py @@ -859,6 +859,7 @@ def changefreqs_generator(): public_versions = Version.internal.public( project=project, only_active=True, + include_hidden=False, ) if not public_versions.exists(): raise Http404()