From dfaac405f0bc905b90f5c6d2bc2aeb6348024a7c Mon Sep 17 00:00:00 2001 From: Lars Olesen Date: Sun, 5 May 2024 12:07:23 +0200 Subject: [PATCH] Fix SEO title when it contains a vertical bar (#3113) * Do not markdownify title * Support markup in titles * Support markup in titles * Fix seo.html as reviewed * seo_title is now unconditionally computed --------- Co-authored-by: iBug --- _includes/seo.html | 18 ++++++++---------- _layouts/archive.html | 2 +- _layouts/single.html | 2 +- 3 files changed, 10 insertions(+), 12 deletions(-) diff --git a/_includes/seo.html b/_includes/seo.html index 0141042b..be147858 100644 --- a/_includes/seo.html +++ b/_includes/seo.html @@ -4,15 +4,13 @@ {%- endif -%} {%- assign seo_url = seo_url | default: site.github.url -%} -{% assign title_separator = site.title_separator | default: '-' | replace: '|', '|' %} +{% assign title_separator = site.title_separator | default: '-' %} -{%- if page.title -%} - {%- assign seo_title = page.title | append: " " | append: title_separator | append: " " | append: site.title -%} -{%- endif -%} +{%- assign page_title = page.title | default: site.title | replace: '|', '|' -%} +{%- assign seo_title = page_title | append: " " | append: title_separator | append: " " | append: site.title | replace: '|', '|' -%} -{%- if seo_title -%} - {%- assign seo_title = seo_title | markdownify | strip_html | strip_newlines | escape_once -%} -{%- endif -%} +{%- assign page_title = page_title | markdownify | strip_html | strip_newlines | escape_once -%} +{%- assign seo_title = seo_title | markdownify | strip_html | strip_newlines | escape_once -%} {% if page.canonical_url %} {%- assign canonical_url = page.canonical_url %} @@ -47,7 +45,7 @@ {%- assign og_type = "website" -%} {%- endif -%} -{{ seo_title | default: site.title }}{% if paginator %}{% unless paginator.page == 1 %} {{ title_separator }} {{ site.data.ui-text[site.locale].page | default: "Page" }} {{ paginator.page }}{% endunless %}{% endif %} +{{ seo_title }}{% if paginator %}{% unless paginator.page == 1 %} {{ title_separator }} {{ site.data.ui-text[site.locale].page | default: "Page" }} {{ paginator.page }}{% endunless %}{% endif %} {% if author.name %} @@ -60,7 +58,7 @@ - + {% if seo_description %} @@ -75,7 +73,7 @@ {% if site.twitter.username %} - + diff --git a/_layouts/archive.html b/_layouts/archive.html index 08beb89a..84c285bc 100644 --- a/_layouts/archive.html +++ b/_layouts/archive.html @@ -23,4 +23,4 @@ layout: default {% endunless %} {{ content }} - \ No newline at end of file + diff --git a/_layouts/single.html b/_layouts/single.html index 5030be26..a36bfa8c 100644 --- a/_layouts/single.html +++ b/_layouts/single.html @@ -22,7 +22,7 @@ layout: default {% include sidebar.html %}
- {% if page.title %}{% endif %} + {% if page.title %}{% endif %} {% if page.excerpt %}{% endif %} {% if page.date %}{% endif %} {% if page.last_modified_at %}{% endif %}