From 4c2828f6fe730bde3cbf2971529db353a7265342 Mon Sep 17 00:00:00 2001 From: Ricardo Date: Tue, 24 Feb 2026 20:52:07 +0100 Subject: [PATCH] fix: remove contentImage from OG meta to prevent sidebar image leaking The extractFirstImage filter picks up tags from the full rendered page content, including sidebar widgets (like recent post thumbnails). This caused og:image to reference sidebar OG images from OTHER posts instead of falling through to the __OG_IMAGE_PLACEHOLDER__ that the og-fix transform resolves from outputPath. Only ogPhoto and image (from frontmatter) are now used as explicit image sources. All other cases use the placeholder resolved by the og-fix transform. --- _includes/layouts/base.njk | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/_includes/layouts/base.njk b/_includes/layouts/base.njk index 28c5ef9..073b096 100644 --- a/_includes/layouts/base.njk +++ b/_includes/layouts/base.njk @@ -13,7 +13,6 @@ {# OpenGraph meta tags #} {% set ogTitle = title | default(site.name) %} {% set ogDesc = description | default(content | ogDescription(200)) | default(site.description) %} - {% set contentImage = content | extractFirstImage %} {# Normalize photo - could be array for multi-photo posts #} {% set ogPhoto = photo %} {% if ogPhoto %} @@ -31,8 +30,6 @@ {% elif image and image != "" and (image | length) > 10 %} - {% elif contentImage and contentImage != "" and (contentImage | length) > 10 %} - {% else %} {% endif %} @@ -41,7 +38,7 @@ {# Twitter Card meta tags #} - {% set hasExplicitImage = (ogPhoto and ogPhoto != "" and (ogPhoto | length) > 10) or (image and image != "" and (image | length) > 10) or (contentImage and contentImage != "" and (contentImage | length) > 10) %} + {% set hasExplicitImage = (ogPhoto and ogPhoto != "" and (ogPhoto | length) > 10) or (image and image != "" and (image | length) > 10) %} @@ -49,8 +46,6 @@ {% elif image and image != "" and (image | length) > 10 %} - {% elif contentImage and contentImage != "" and (contentImage | length) > 10 %} - {% else %} {% endif %} @@ -98,8 +93,8 @@ - {% if site.markdownAgents.enabled and page.url and page.url.startsWith('/articles/') %} - + {% if site.markdownAgents.enabled and page.url and page.url.startsWith('/articles/') and page.url != '/articles/' %} + {% endif %}