fix: handle absolute URLs in JSON-LD image field

When markdown images use full https:// URLs, the template was prepending
site.url again, causing double-domain in structured data
(e.g., https://rmendes.net/https://rmendes.net/media/...).

Now checks if postImage starts with 'http' and skips the prefix.
This commit is contained in:
Ricardo
2026-02-26 14:56:13 +01:00
parent 1895584870
commit dbd2f72019
+1 -1
View File
@@ -242,7 +242,7 @@ withBlogSidebar: true
} }
}, },
"description": {{ postDesc | dump | safe }}{% if postImage and postImage != "" and (postImage | length) > 10 %}, "description": {{ postDesc | dump | safe }}{% if postImage and postImage != "" and (postImage | length) > 10 %},
"image": ["{{ site.url }}{% if '/' in postImage and postImage[0] == '/' %}{{ postImage }}{% else %}/{{ postImage }}{% endif %}"]{% endif %} "image": ["{% if postImage.startsWith('http') %}{{ postImage }}{% elif '/' in postImage and postImage[0] == '/' %}{{ site.url }}{{ postImage }}{% else %}{{ site.url }}/{{ postImage }}{% endif %}"]{% endif %}
} }
</script> </script>
</article> </article>