Skip to content

Commit 344c357

Browse files
chezouclaude
andcommitted
fix: use get_featured_image partial consistently for og:image and JSON-LD
site_head.html, jsonld/article.html, jsonld/qapage.html, and jsonld/event.html hardcode `(.Resources.ByType "image").GetMatch "*featured*"` to find featured images. This ignores custom filenames set via `.Params.image.filename` in front matter, causing og:image and JSON-LD image to fall back to the site icon. Replace the hardcoded pattern with the `get_featured_image` partial (already used by jsonld/webpage.html), which properly searches for: 1. Files matching `*featured*` in the page directory 2. Custom filename from `.Params.image.filename` in the page directory 3. Custom filename in `assets/media/` directory Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent f54d1c8 commit 344c357

File tree

4 files changed

+4
-4
lines changed

4 files changed

+4
-4
lines changed

modules/blox/layouts/_partials/jsonld/article.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{{- $page := .page }}
22
{{ $summary := .summary }}
3-
{{ $featured_image := ($page.Resources.ByType "image").GetMatch "*featured*" }}
3+
{{ $featured_image := partial "functions/get_featured_image" $page }}
44

55
{{/* Get schema type. */}}
66
{{ $schema := "Article" }}

modules/blox/layouts/_partials/jsonld/event.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{{ $page := .page }}
22
{{ $summary := .summary }}
3-
{{ $featured_image := ($page.Resources.ByType "image").GetMatch "*featured*" }}
3+
{{ $featured_image := partial "functions/get_featured_image" $page }}
44
{{ $author := partial "functions/get_author_name" $page }}
55

66
<script type="application/ld+json">

modules/blox/layouts/_partials/jsonld/qapage.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{{- $page := .page }}
22
{{ $summary := .summary }}
3-
{{ $featured_image := ($page.Resources.ByType "image").GetMatch "*featured*" }}
3+
{{ $featured_image := partial "functions/get_featured_image" $page }}
44

55
{{/* Get author and publisher info */}}
66
{{ $author := partial "functions/get_author_name" $page }}

modules/blox/layouts/_partials/site_head.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@
116116

117117
{{/* Get page image for sharing. */}}
118118
{{ $sharing_image := resources.GetMatch (path.Join "media" "sharing.*") }}
119-
{{ $featured_image := (.Resources.ByType "image").GetMatch "*featured*" }}
119+
{{ $featured_image := partial "functions/get_featured_image" . }}
120120
{{ $avatar_image := (.Resources.ByType "image").GetMatch "avatar*" }}
121121
{{ $has_logo := fileExists "assets/media/logo.png" | or (fileExists "assets/media/logo.svg") }}
122122
{{ $og_image := "" }}

0 commit comments

Comments
 (0)