From ff7700d603443de62f5509c918968668e49beea6 Mon Sep 17 00:00:00 2001 From: Sarah Gibson Date: Tue, 27 Aug 2024 11:35:29 +0100 Subject: [PATCH 1/2] ReadTheDocs: set canonical custom domain in prep for addons migration --- docs/conf.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/docs/conf.py b/docs/conf.py index 0b5b2e4a1..6b694feab 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -77,6 +77,7 @@ def setup(app): app.add_css_file("custom.css") +import os import subprocess # -- Custom scripts ----------------------------------------- @@ -84,3 +85,13 @@ def setup(app): ["python", "helper-programs/generate-general-info-table-about-hubs.py"], check=True ) subprocess.run(["python", "helper-programs/generate-hub-features-table.py"], check=True) + +# -- Set canonical custom domain via html_baseurl ----------- +# -- See https://github.com/2i2c-org/infrastructure/issues/4629 + +# Set canonical URL from the Read the Docs Domain +html_baseurl = os.environ.get("READTHEDOCS_CANONICAL_URL", "") + +# Tell Jinja2 templates the build is running on Read the Docs +if os.environ.get("READTHEDOCS", "") == "True": + html_context["READTHEDOCS"] = True From d69cb0fdf1a4e68eb60ebfa2c8da357835e622a2 Mon Sep 17 00:00:00 2001 From: Sarah Gibson Date: Tue, 27 Aug 2024 11:40:07 +0100 Subject: [PATCH 2/2] Add an empty dict for html_context Received NameError: name 'html_context' is not defined in previous commit --- docs/conf.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/conf.py b/docs/conf.py index 6b694feab..313d22c3b 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -77,6 +77,8 @@ def setup(app): app.add_css_file("custom.css") +html_context = {} + import os import subprocess