@@ -25,6 +25,7 @@ def setup(app):
25
25
app .add_html_theme (name , path )
26
26
27
27
app .add_config_value ("is_pallets_theme" , None , "html" )
28
+ app .add_config_value ("rtd_canonical_path" , "/en/stable/" , "html" )
28
29
29
30
# Use the sphinx-notfound-page extension to generate a 404 page with valid
30
31
# URLs. Only configure it if it's not already configured.
@@ -67,16 +68,16 @@ def setup(app):
67
68
@only_pallets_theme ()
68
69
def find_base_canonical_url (app : Sphinx ) -> None :
69
70
"""When building on Read the Docs, build the base canonical URL from the
70
- environment variable if it's not given in the config. Read the Docs has a
71
- special `/page/<path>` rule that redirects any path to the current version
72
- of the docs, so that's used as the canonical link.
71
+ environment variable if it's not given in the config. Replace the path with
72
+ ``rtd_canonical_path``, which defaults to ``/en/stable/``.
73
73
"""
74
74
if app .config .html_baseurl :
75
75
return
76
76
77
77
if "READTHEDOCS_CANONICAL_URL" in os .environ :
78
78
parts = urlsplit (os .environ ["READTHEDOCS_CANONICAL_URL" ])
79
- app .config .html_baseurl = f"{ parts .scheme } ://{ parts .netloc } /page/"
79
+ path = app .config .rtd_canonical_path
80
+ app .config .html_baseurl = f"{ parts .scheme } ://{ parts .netloc } { path } "
80
81
81
82
82
83
@only_pallets_theme ()
0 commit comments