From ca4a650941a7a77c36a8a8243425bf75a5b28f12 Mon Sep 17 00:00:00 2001 From: Imran Siddique Date: Thu, 20 Aug 2026 21:36:02 -0700 Subject: [PATCH] fix(seo): social cards said "Home", not the page title MkDocs sets page.title from the nav entry when the nav gives one, so a landing page listed as "- Home: index.md" reports page.title == "Home". The tag was right, because Material reads the front matter for it, but og:title and twitter:title read page.title and shipped og:title = "Home - TRACE" to every link preview. My own change introduced this: the previous expression suppressed the homepage title entirely and fell back to the site name, so the regression turned a bare "TRACE" into "Home - TRACE". page.meta.title is the front-matter value. Prefer it, fall back to page.title for inner pages, then to the site name. Verified per site: the homepage og:title now matches its <title>, and inner pages keep their own. Builds clean under --strict. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013EQx4N5BzTQbY8kvXUsdkY --- overrides/main.html | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/overrides/main.html b/overrides/main.html index 7cd12af..1a9a1e3 100644 --- a/overrides/main.html +++ b/overrides/main.html @@ -12,7 +12,9 @@ {% block extrahead %} {{ super() }} - {% set page_title = page.title ~ " - " ~ config.site_name if page and page.title else config.site_name %} + {# page.title is the nav label ("Home"); page.meta.title is the front matter. #} + {% set page_name = (page.meta.title if page and page.meta and page.meta.title else (page.title if page else None)) %} + {% set page_title = page_name ~ " - " ~ config.site_name if page_name else config.site_name %} {% set page_desc = page.meta.description if page and page.meta and page.meta.description else config.site_description %} {% set page_url = page.canonical_url if page and page.canonical_url else config.site_url %}