{{- /* The image that represents a page - shared between opengraph.html (og:image/ twitter:image) and jsonld.html (BlogPosting.image), so the same priority logic can't drift between the two the way it would copied twice. Takes the page being rendered, returns a dict of url/width/height (width/height 0 when unknown, which is only the front-matter-`images` case: an arbitrary reader-supplied path isn't a Hugo resource this can measure). Priority: front matter `images` (Hugo's own convention) wins, in case a post ever wants to hand-pick its own; then the generated card every post gets (og-card.png, a real Chromium screenshot of this same page taken by flake.nix's buildPhase - not present under plain `hugo`/`hugo server`, only the Nix build, so a local preview falls through to the avatar instead); the site avatar is the last resort so a page never has no image at all. The og-card step is for posts specifically, not for pages in general: flake.nix finds what to screenshot by globbing $out for /YYYY/MM/DD/slug/ directories, which is the posts permalink pattern from hugo.toml and nothing else. A standalone page - /talks/ - is a .IsPage all the same, so testing that alone had it advertise an og-card.png that no build step ever writes. It falls through to the avatar instead, which is a real image. */ -}} {{- $page := . }} {{- $url := "" }} {{- $width := 0 }} {{- $height := 0 }} {{- with $page.Params.images }} {{- with index . 0 }}{{ $url = . | absURL }}{{ end }} {{- end }} {{- if and (not $url) $page.IsPage (eq $page.Section "posts") }} {{- $url = printf "%sog-card.png" $page.Permalink }} {{- $width = 1200 }} {{- $height = 630 }} {{- end }} {{- if not $url }} {{- with site.Params.profile.avatar }} {{- with resources.Get . }} {{- $url = .Permalink }} {{- $width = .Width }} {{- $height = .Height }} {{- end }} {{- end }} {{- end }} {{- return (dict "url" $url "width" $width "height" $height) }}