Fix blog page title showing post name twice
Stop concatenating post title into base_title in route context. Build proper "Post Title — Site Title" format in meta component instead. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -125,7 +125,7 @@ def register(url_prefix, title):
|
||||
|
||||
ctx = {
|
||||
**p_data,
|
||||
"base_title": f"{get_config()['title']} {p_data['post']['title']}",
|
||||
"base_title": get_config()["title"],
|
||||
"container_nav_html": container_nav_html,
|
||||
}
|
||||
|
||||
|
||||
@@ -78,7 +78,7 @@ def register():
|
||||
|
||||
ctx = {
|
||||
**p_data,
|
||||
"base_title": f"{config()['title']} {p_data['post']['title']}",
|
||||
"base_title": config()["title"],
|
||||
"container_nav_html": container_nav_html,
|
||||
}
|
||||
|
||||
|
||||
@@ -31,10 +31,10 @@
|
||||
(when html-content (div :class "blog-content p-2" (raw! html-content))))
|
||||
(div :class "pb-8")))
|
||||
|
||||
(defcomp ~blog-meta (&key robots base-title desc canonical og-type og-title image twitter-card twitter-title)
|
||||
(defcomp ~blog-meta (&key robots page-title desc canonical og-type og-title image twitter-card twitter-title)
|
||||
(<>
|
||||
(meta :name "robots" :content robots)
|
||||
(title base-title)
|
||||
(title page-title)
|
||||
(meta :name "description" :content desc)
|
||||
(when canonical (link :rel "canonical" :href canonical))
|
||||
(meta :property "og:type" :content og-type)
|
||||
|
||||
@@ -846,12 +846,14 @@ def _post_meta_html(ctx: dict) -> str:
|
||||
from quart import request as req
|
||||
canonical = post.get("canonical_url") or (req.url if req else "")
|
||||
|
||||
og_title = post.get("og_title") or base_title
|
||||
tw_title = post.get("twitter_title") or base_title
|
||||
post_title = post.get("meta_title") or post.get("title") or ""
|
||||
page_title = f"{post_title} \u2014 {base_title}" if post_title else base_title
|
||||
og_title = post.get("og_title") or page_title
|
||||
tw_title = post.get("twitter_title") or page_title
|
||||
is_article = not post.get("is_page")
|
||||
|
||||
return render("blog-meta",
|
||||
robots=robots, base_title=base_title, desc=desc, canonical=canonical,
|
||||
robots=robots, page_title=page_title, desc=desc, canonical=canonical,
|
||||
og_type="article" if is_article else "website",
|
||||
og_title=og_title, image=image,
|
||||
twitter_card="summary_large_image" if image else "summary",
|
||||
|
||||
Reference in New Issue
Block a user