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 '//' %}
|
<!-- it's a cross-origin URL -->
|
||||||
<!-- `site.img_cdn` is a cross-origin URL -->
|
{% capture replacement %}"{{ site.img_cdn }}{{ page.img_path }}{{ page.image.path }}"{% endcapture %}
|
||||||
{% capture target %}<meta property="{{ prop }}" content="{{ site.url }}{% endcapture %}
|
{% else %}
|
||||||
{% capture replacement %}<meta property="{{ prop }}" content="{{ site.img_cdn }}{% endcapture %}
|
<!-- it's a local file path -->
|
||||||
{% else %}
|
{%- capture replacement -%}
|
||||||
<!-- `site.img_cdn` is a local file path -->
|
"{{ site.url }}{{ site.baseurl }}{{ site.img_cdn }}{{ page.img_path }}{{ page.image.path }}"
|
||||||
{% capture target %}<meta property="{{ prop }}" content="{{ site.url }}{{ site.baseurl }}{% endcapture %}
|
{%- endcapture -%}
|
||||||
{% assign replacement = target | append: site.img_cdn %}
|
{% 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