From f6e9a3fccf7ab34db71f8aefaf86fdcc05861076 Mon Sep 17 00:00:00 2001 From: Cotes Chung <11371340+cotes2020@users.noreply.github.com> Date: Thu, 17 Nov 2022 07:31:05 +0800 Subject: [PATCH] fix: the image URL in the SEO-related tags is incomplete (#754) This issue occurs when setting the `img_path` of the post or the `baseurl` of the site configuration. --- _includes/head.html | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/_includes/head.html b/_includes/head.html index 0947587..8e3756a 100644 --- a/_includes/head.html +++ b/_includes/head.html @@ -22,23 +22,21 @@ {% seo title=false %} {% endcapture %} - {% if site.img_cdn and seo_tags contains 'og:image' %} - {% assign properties = 'og:image,twitter:image' | split: ',' %} + {% if page.image.path %} + {% capture target %}"{{ site.url }}{{ page.image.path | relative_url }}"{% endcapture %} - {% for prop in properties %} - {% if site.img_cdn contains '//' %} - - {% capture target %} + {%- capture replacement -%} + "{{ site.url }}{{ site.baseurl }}{{ site.img_cdn }}{{ page.img_path }}{{ page.image.path }}" + {%- endcapture -%} + {% endif %} - {% assign seo_tags = seo_tags | replace: target, replacement %} + {% assign seo_tags = seo_tags | replace: target, replacement %} - {% endfor %} {% endif %} {{ seo_tags }}