Instatic icon indicating copy to clipboard operation
Instatic copied to clipboard

[Feature]: Emit Open Graph and X card tags so link previews stop picking a random page image

Open borskyj-symph opened this issue 2 months ago • 0 comments

Problem

Published pages carry no Open Graph or X card tags. assembleHtmlDocument (src/core/publisher/render.ts:504 on main, f92e8dc1) writes charset, viewport, CSP, <title>, an optional <meta name="description"> and the favicon, and nothing else. There is no setting, field or plugin hook that adds og:* / twitter:* to <head>.

Without them, every link preview (Teams, Slack, WhatsApp, LinkedIn, Facebook, iMessage) guesses. The scrapers take the first raster <img> they find in the body. Header logos are usually SVG, which these scrapers skip, so the preview picks whatever photo happens to come first.

Real case: our /contact page shows a full portrait of one colleague as the preview image, because her photo in a booking block is the first non-SVG image. Other pages show equally random pictures. Nobody can fix this from the admin.

Two related gaps make the preview text worse:

  • The description falls back to the single site-wide settings.metaDescription on every regular page, so every shared link has the same text.
  • On a multilingual site the English pages get the Czech description, since there is only one.

Proposed solution

Smallest useful version, in buildDocumentMetaTags / assembleHtmlDocument:

  1. Always emit og:title and og:description from the values already resolved for <title> and <meta name="description">, plus og:type (website, or article for post-type entries) and og:site_name.
  2. Emit og:url when the site has a configured public origin (never guess a host).
  3. A site-level default social image setting (media picker), emitted as og:image + og:image:width/height and twitter:card=summary_large_image. With no image set, emit twitter:card=summary and no og:image.
  4. Optional per-target override: a social image field on post-type entries (and on pages once page SEO fields are wired, see below), taking precedence over the site default.

Absolute URLs for og:image and og:url should come from the configured public origin, since scrapers do not resolve relative URLs reliably.

Alternatives considered

  • Meta tags in an HTML block in the body. Some scrapers tolerate og:* outside <head>, most (Teams, LinkedIn) do not. Not a real fix.
  • A plugin. The plugin SDK has no hook into <head>, so it can't do this either.
  • Draft PR #53 (SEO & AEO workspace) covers Open Graph, X cards, JSON-LD, canonical and sitemap together, but it has been a draft since June and is a large change. This issue asks for the social-preview slice alone, which could land independently and later be absorbed by #53's resolver.

Related: #522 (per-page robots meta), #419 (entry SEO title/description in <head>).

I'm happy to open a PR for points 1–3 if the approach looks right.

borskyj-symph avatar Sep 23 '26 06:09 borskyj-symph