Skip to content

feat(og): dynamic per-article Open Graph images#48

Merged
HeyItsGilbert merged 2 commits into
mainfrom
feat/dynamic-og-images
Jun 27, 2026
Merged

feat(og): dynamic per-article Open Graph images#48
HeyItsGilbert merged 2 commits into
mainfrom
feat/dynamic-og-images

Conversation

@HeyItsGilbert

Copy link
Copy Markdown
Member

What & why

The site shipped no og:image at all — links shared to Slack/Discord/X/LinkedIn/iMessage rendered a blank or random preview. This adds:

  1. A default branded social card for every page.
  2. Build-time generation of per-article cards when an article sets og_title front matter.

It uses native Hugo image processing (images.Text) — no headless browser, no runtime service, no CI changes. Everything happens inside the existing hugo --gc --minify step.

How authors opt in

og_title: How to Write for PowerShell.org
og_description: Two ways to submit an article, best practices that get you published faster…  # optional; falls back to `description`

No og_title → the page uses a per-page image: override if set, else the site-wide default card.

How it works

  • partials/og-image.html word-wraps the title (max 3 lines) and description and composites them onto assets/og/og-base.png via images.Text, returning a content-hashed URL.
  • baseof.html now emits og:image / twitter:image (+ width/height/alt) pointing at that URL.
  • Inter (Bold/Regular, OFL-licensed) is bundled because images.Text needs a local TTF.
  • resources/_gen/ (Hugo''s image cache) is gitignored — regenerated deterministically each build.

Caching

Generated filenames are content-hashed (og-base_hu_<hash>.png), so editing an article''s title/description yields a new URL — CDN edge caches and social-platform scraper caches bust automatically. Unchanged pages keep a stable URL and stay warm.

Verification

  • hugo build succeeds; article with og_title gets a generated card, home/other pages keep the default. Confirmed the rendered tags and inspected the output PNG (1200×630).

Notes

  • Visual tradeoff vs. a browser-rendered card: flat white Inter text (no gradient title / live terminal) — the cost of staying browser-free.
  • Wrapping is character-heuristic (title ~26 chars, desc ~64); tuned for typical titles.
  • This PR is infrastructure only. I deliberately left the in-progress edits to content/articles/2026-06-23-how-to-write-for-powershell-org.md out so they can land separately; happy to add a live og_title example in a follow-up.

🤖 Generated with Claude Code

The site shipped no og:image at all — shares rendered blank. Add a
default branded social card plus build-time generation of per-article
cards when an article sets `og_title` front matter.

- Wire og:image/twitter:image (+ dimensions/alt) into baseof.html
- Add partials/og-image.html: composites the title (word-wrapped, max 3
  lines) and description onto a branded base card via Hugo's images.Text,
  falling back to a per-page `image` or the site default
- Add the base card (assets/og/og-base.png) and default card
  (static/images/og-image.png), built from the PowerShell.org design system
- Bundle Inter (Bold/Regular, OFL) for images.Text
- Ignore resources/_gen (Hugo image cache, regenerated each build)

Native Hugo image processing — no headless browser or runtime service,
runs inside the existing build. Filenames are content-hashed, so CDN and
social-scraper caches bust automatically when an article's text changes.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@netlify

netlify Bot commented Jun 27, 2026

Copy link
Copy Markdown

Deploy Preview for powershellorg ready!

Name Link
🔨 Latest commit f9435f7
🔍 Latest deploy log https://app.netlify.com/projects/powershellorg/deploys/6a405a8d553b9f0008da516d
😎 Deploy Preview https://deploy-preview-48--powershellorg.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

- Added Open Graph metadata for better social sharing.
- Standardized author field to use an array format.
- Corrected tag capitalization for consistency.
@HeyItsGilbert HeyItsGilbert merged commit f683b78 into main Jun 27, 2026
5 checks passed
@HeyItsGilbert HeyItsGilbert deleted the feat/dynamic-og-images branch June 27, 2026 23:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant