From 829d1c8db2c5ddf021e7bb3f323443301e39048d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pekka=20Kl=C3=A4rck?= Date: Thu, 10 Oct 2024 11:06:56 +0300 Subject: [PATCH] Fixed social cards not using site name on homepage (#7608) Use `config.site_name` instead of `page.title`. --- material/plugins/social/plugin.py | 8 +++++--- src/plugins/social/plugin.py | 8 +++++--- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/material/plugins/social/plugin.py b/material/plugins/social/plugin.py index 291d79cf4..3ca2a9798 100644 --- a/material/plugins/social/plugin.py +++ b/material/plugins/social/plugin.py @@ -339,9 +339,11 @@ class SocialPlugin(BasePlugin[SocialConfig]): file, _ = os.path.splitext(page.file.src_uri) # Compute page title - title = page.meta.get("title", page.title) - if not page.is_homepage: - title = f"{title} - {config.site_name}" + if page.is_homepage: + title = config.site_name + else: + page_title = page.meta.get("title", page.title) + title = f"{page_title} - {config.site_name}" # Compute page description description = config.site_description diff --git a/src/plugins/social/plugin.py b/src/plugins/social/plugin.py index 291d79cf4..3ca2a9798 100644 --- a/src/plugins/social/plugin.py +++ b/src/plugins/social/plugin.py @@ -339,9 +339,11 @@ class SocialPlugin(BasePlugin[SocialConfig]): file, _ = os.path.splitext(page.file.src_uri) # Compute page title - title = page.meta.get("title", page.title) - if not page.is_homepage: - title = f"{title} - {config.site_name}" + if page.is_homepage: + title = config.site_name + else: + page_title = page.meta.get("title", page.title) + title = f"{page_title} - {config.site_name}" # Compute page description description = config.site_description