Skip to content

Commit 82e0e0a

Browse files
twieckiclaude
andauthored
Fix broken canonical URLs in the example gallery (#893)
* Fix canonical URLs and stale blog base URL html_baseurl was missing the /en/latest/ segment, so the canonical URL Sphinx writes into every page pointed at a URL that redirects to a 404. Old versioned builds therefore keep competing with latest in search engines instead of transferring their ranking. Sitemap URLs are unchanged: the version prefix moves from sitemap_url_scheme into the base URL. Also point blog_baseurl at www.pymc.io instead of the old docs.pymc.io domain. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> * Give the gallery page a real meta description and intro The generated gallery.rst had no description, so search engines built the snippet from concatenated card titles ('Introductory: General Overview Introductory Overview of PyMC Simple Linear Regression...'). The gallery page has 269k search impressions at 1.3% CTR. Add an explicit meta description plus a one-sentence visible intro. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> --------- Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
1 parent 5ae7aab commit 82e0e0a

2 files changed

Lines changed: 13 additions & 3 deletions

File tree

examples/conf.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,11 @@ def setup(app: Sphinx):
7171

7272
# theme options
7373
html_theme = "pymc_sphinx_theme"
74-
html_baseurl = "https://www.pymc.io/projects/examples/"
74+
# Also used to build each page's canonical URL, so it points at the default
75+
# (latest) version: <html_baseurl> + <page name>.html
76+
html_baseurl = "https://www.pymc.io/projects/examples/en/latest/"
7577
rtd_version = os.environ.get("READTHEDOCS_VERSION", "")
76-
sitemap_url_scheme = f"{{lang}}{rtd_version}/{{link}}"
78+
sitemap_url_scheme = "{link}"
7779
html_theme_options = {
7880
"secondary_sidebar_items": ["postcard", "page-toc", "edit-this-page", "sourcelink", "donate"],
7981
"navbar_start": ["navbar-logo"],
@@ -127,7 +129,7 @@ def setup(app: Sphinx):
127129
}
128130

129131
# ablog config
130-
blog_baseurl = "https://docs.pymc.io/projects/examples/en/latest/"
132+
blog_baseurl = "https://www.pymc.io/projects/examples/en/latest/"
131133
blog_title = "PyMC Examples"
132134
blog_path = "blog"
133135
blog_authors = {

sphinxext/thumbnail_extractor.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,14 @@
2828
PyMC Example Gallery
2929
====================
3030
31+
.. meta::
32+
:description: Hundreds of runnable PyMC example notebooks: regression,
33+
hierarchical models, Gaussian processes, time series, causal
34+
inference, and more Bayesian modeling recipes.
35+
36+
A collection of runnable Jupyter notebooks showing how to solve real modeling
37+
problems with PyMC, from simple regression to advanced Bayesian workflows.
38+
3139
.. toctree::
3240
:hidden:
3341

0 commit comments

Comments
 (0)