Files
HugoBlox-kit/modules/blox/layouts/_partials/jsonld/article.html
T
Aki ArigaandClaude Opus 4.6 611be3562f feat: use get_featured_image partial consistently for og:image and JSON-LD (#3311)
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>
2026-03-30 20:29:18 +01:00

49 lines
1.2 KiB
HTML

{{- $page := .page }}
{{ $summary := .summary }}
{{ $featured_image := partial "functions/get_featured_image" $page }}
{{/* Get schema type. */}}
{{ $schema := "Article" }}
{{ if eq $page.Type "blog" }}
{{ $schema = "BlogPosting" }}
{{ end }}
{{ $author := partial "functions/get_author_name" $page }}
{{ $branding := partialCached "functions/get_branding" $page "branding" }}
{{ $publisher := $branding.organization }}
{{ $logo_url := partial "functions/get_logo_url" $page -}}
<script type="application/ld+json">
{
"@context": "https://schema.org",
"@type": {{$schema}},
"mainEntityOfPage": {
"@type": "WebPage",
"@id": {{$page.Permalink}}
},
"headline": {{$page.Title}},
{{ if $featured_image }}
"image": [
{{$featured_image.Permalink}}
],
{{end}}
"datePublished": {{ $page.PublishDate.Format "2006-01-02T15:04:05Z07:00" }},
"dateModified": {{ $page.Lastmod.Format "2006-01-02T15:04:05Z07:00" }},
{{with $author}}
"author": {
"@type": "Person",
"name": {{.}}
},
{{end}}
"publisher": {
"@type": "Organization",
"name": {{$publisher}},
"logo": {
"@type": "ImageObject",
"url": {{$logo_url}}
}
},
"description": {{$summary}}
}
</script>