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.
This commit is contained in:
parent
ae2669fedc
commit
f6e9a3fccf
1 changed files with 12 additions and 14 deletions
|
@ -22,23 +22,21 @@
|
||||||
{% seo title=false %}
|
{% seo title=false %}
|
||||||
{% endcapture %}
|
{% endcapture %}
|
||||||
|
|
||||||
{% if site.img_cdn and seo_tags contains 'og:image' %}
|
{% if page.image.path %}
|
||||||
{% assign properties = 'og:image,twitter:image' | split: ',' %}
|
{% capture target %}"{{ site.url }}{{ page.image.path | relative_url }}"{% endcapture %}
|
||||||
|
|
||||||
{% for prop in properties %}
|
|
||||||
{% if site.img_cdn contains '//' %}
|
{% if site.img_cdn contains '//' %}
|
||||||
<!-- `site.img_cdn` is a cross-origin URL -->
|
<!-- it's a cross-origin URL -->
|
||||||
{% capture target %}<meta property="{{ prop }}" content="{{ site.url }}{% endcapture %}
|
{% capture replacement %}"{{ site.img_cdn }}{{ page.img_path }}{{ page.image.path }}"{% endcapture %}
|
||||||
{% capture replacement %}<meta property="{{ prop }}" content="{{ site.img_cdn }}{% endcapture %}
|
|
||||||
{% else %}
|
{% else %}
|
||||||
<!-- `site.img_cdn` is a local file path -->
|
<!-- it's a local file path -->
|
||||||
{% capture target %}<meta property="{{ prop }}" content="{{ site.url }}{{ site.baseurl }}{% endcapture %}
|
{%- capture replacement -%}
|
||||||
{% assign replacement = target | append: site.img_cdn %}
|
"{{ site.url }}{{ site.baseurl }}{{ site.img_cdn }}{{ page.img_path }}{{ page.image.path }}"
|
||||||
|
{%- endcapture -%}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{% assign seo_tags = seo_tags | replace: target, replacement %}
|
{% assign seo_tags = seo_tags | replace: target, replacement %}
|
||||||
|
|
||||||
{% endfor %}
|
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{{ seo_tags }}
|
{{ seo_tags }}
|
||||||
|
|
Loading…
Reference in a new issue