Static site generator
Add automatic MyOG.social images to Hugo sites by extending or replacing the Open Graph partial.
Hugo includes embedded Open Graph templates, and themes often call partials/opengraph.html from the head.
MyOG works well as a partial because Hugo can generate the absolute permalink for every page at build time.
This is not a plugin candidate. Hugo users will prefer a short partial they can drop into their theme override directory.
MyOG detects page content and branding automatically. The layout only controls image composition.
Place this in layouts/_partials/myog.html and call it from your head template.
{{- $pageURL := .Permalink | urlquery -}}
{{- $myogImageURL := printf "https://api.myog.social/og?url=%s&template=screenshot-right" $pageURL -}}
<meta property="og:image" content="{{ $myogImageURL | safeHTMLAttr }}" />
<meta property="og:image:width" content="1200" />
<meta property="og:image:height" content="630" />
<meta name="twitter:card" content="summary_large_image" />
<meta name="twitter:image" content="{{ $myogImageURL | safeHTMLAttr }}" />Call it with {{ partial "myog.html" . }} near your existing Open Graph partial.
Hugo's embedded Open Graph partial may emit images from front matter. If you keep that partial and add MyOG after it, crawlers may keep using the first image. Replace the image section or conditionally skip the embedded partial image output.
Use .Permalink for regular pages, list pages, taxonomy pages, and posts. It resolves from baseURL and the current page path at build time.
Start with the MyOG Open Graph Checker, then refresh social platform caches if needed.
Sign up for free and add generated OG images to Hugo posts and pages.
Already have an account?
cdf733b534ea2f2ed964d150330b323c44837e4f