Skip to content

Commit 6e60c72

Browse files
authored
Use correct canonical URL while building docs (#6829)
As noted in readthedocs/readthedocs.org#10224 with the current configuration the canonical URL is wrong with different sphinx builds. For instance the "latest" docs point to "stable". This leads to apps like Mastodon to generate previews to pages which don't exist since they rely on <link rel="canonical" href="https://jupyter-notebook.readthedocs.io/en/stable/notebook_7_features.html" /> This should fix that.
1 parent 2f9aa01 commit 6e60c72

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

docs/source/conf.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,11 @@
265265
# Output file base name for HTML help builder.
266266
htmlhelp_basename = "JupyterNotebookdoc"
267267

268+
# This will ensure that we use the correctly set environment for canonical URLs
269+
# Old Read the Docs injections makes it point only to the default version,
270+
# for instance /en/stable/
271+
html_baseurl = os.environ.get("READTHEDOCS_CANONICAL_URL", "/")
272+
268273
# -- Options for LaTeX output ---------------------------------------------
269274

270275
latex_elements = {}

0 commit comments

Comments
 (0)