From e69a3fd0a646c61e5c354bd396cfa59e73e616fd Mon Sep 17 00:00:00 2001 From: Markus Graf Date: Sat, 6 Jun 2026 12:40:36 +0200 Subject: [PATCH] feat: add Open Graph and Twitter Card meta tags for social sharing --- layouts/_default/baseof.html | 2 ++ layouts/partials/opengraph.html | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+) create mode 100644 layouts/partials/opengraph.html diff --git a/layouts/_default/baseof.html b/layouts/_default/baseof.html index e844873..191fadf 100644 --- a/layouts/_default/baseof.html +++ b/layouts/_default/baseof.html @@ -6,6 +6,8 @@ {{ if .IsHome }}{{ .Site.Title }}{{ else }}{{ .Title }} | {{ .Site.Title }}{{ end }} + {{ partial "opengraph.html" . }} + diff --git a/layouts/partials/opengraph.html b/layouts/partials/opengraph.html new file mode 100644 index 0000000..8b81d43 --- /dev/null +++ b/layouts/partials/opengraph.html @@ -0,0 +1,32 @@ +{{/* Open Graph / Social Media Meta Tags */}} + +{{/* Basic OG tags */}} + + + + + + + +{{/* Article-specific tags */}} +{{ if .IsPage }} + +{{ with .Lastmod }}{{ end }} +{{ end }} + +{{/* Image handling: only render if images defined in frontmatter */}} +{{ with .Params.images }} + {{ range first 1 . }} + {{ $img := . }} + {{ if not (hasPrefix $img "http") }} + {{ $img = printf "%s%s" $.Permalink $img }} + {{ end }} + + + {{ end }} +{{ end }} + +{{/* Twitter Card */}} + + +