Open graph for images in multipage posts

Follow up to this topic, what is the correct way to make the ‘og image’ in the head.html to apply to the subpages when the image is placed at the root? cc @jmooring

Is the image consistently named something like “” for each multipage post?

Yes. featured-image.jpg.


{{ with .Resources.GetMatch "featured-image.*" }}
  <meta property="og:image" content="{{ .Permalink }}">
{{ else }}
  {{ if and (eq .Params.layout "multipage") (eq .Kind "page") }}
    {{ with .Parent.Resources.GetMatch "featured-image.*" }}
        <meta property="og:image" content="{{ .Permalink }}">
    {{ end }}
  {{ end }}
{{ end }}

I’ve updated the example site we used previously:

git clone --single-branch -b hugo-forum-topic-41042 hugo-forum-topic-41042
cd hugo-forum-topic-41042
hugo server

Solved. Thanks.

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.