Skip to Content
Documentation

SEO

Social images

Give every VitNode page an og:image. The API draws 1200 × 630 cards for content, member profiles and the site, with your own colours, fonts and templates.

When someone shares a VitNode link on Facebook, LinkedIn, X, Slack or Discord, the preview shows the page's og:image. VitNode fills it for you: the API draws a social card, and every page head points at it. The card is headed by the site's logo, with the page's title as the headline, its description underneath, and a soft glow of your accent colour lighting up the right side. No headless browser runs, and nothing is fetched from the internet: the fonts ship with VitNode.

A dark social card with the VitNode logo at the top left, the story's excerpt as a large quote, the title Hello Content Engine and the domain below it, and a soft blue glow on the right

What each page gets

Pageog:image
A Content Engine record whose type sets delivery.seo.openGraphIts card at /api/{plugin}/content/{path}/delivery/og/{slug}
A member profile (/users/{nameCode})The member's card at /api/@vitnode/core/og/users/{nameCode}: name, profile headline and avatar
Any other page with a titleThe site card at /api/@vitnode/core/og/site, drawn with the page's own title and description from the URL

Give the site card a coloured label with openGraph:

apps/web/src/routes/_docs/docs.$.tsx
head: ({ loaderData }) =>
  pageHead({
    title: loaderData?.metaTitle,
    description: loaderData?.description,
    openGraph: {
      imageCategory: { title: "Content Engine", color: "#61bd67" },
    },
  }),
  • imageCategory puts a label above the title, and its color (#rrggbb) tints the label, the glow and the bar at the bottom. VitNode's docs use it for the section a page lives in.
  • imageLayout: "quote" swaps the headline for a pull quote: the description large, signed with the title.

A page with a title also gets og:title, og:description, og:type, og:site_name, og:url (its canonical URL), og:locale (as en_US, even when the locale is just en), one og:locale:alternate per other language it has alternates in, and the X card tags twitter:card, twitter:title, twitter:description, twitter:image and twitter:image:alt. A layout that only sets robots gets none of them.

Set metadata.twitterSite to your X handle and every page also gets twitter:site:

apps/web/src/vitnode.config.ts
export const vitNodeConfig = buildConfig({
  metadata: {
    title: "Acme Community",
    twitterSite: "@acme",
  },
  // ...
});

Pages that pass no canonical URL or locale still get og:url and og:locale from the root route. Add documentSocialMeta to its head, and give it the public pathname from beforeLoad:

apps/web/src/routes/__root.tsx
import { documentSocialMeta } from "@vitnode/core/tanstack/metadata";

export const Route = createRootRouteWithContext<RootRouterContext>()({
  beforeLoad: ({ location }) => {
    const publicPathname = publicPathnameOf(location);

    return { locale: resolveLocale<Locale>(publicPathname), publicPathname };
  },
  head: ({ match }) => ({
    meta: [
      ...documentSocialMeta({
        locale: match.context.locale,
        pathname: match.context.publicPathname,
      }),
    ],
  }),
});

Each card URL carries a v version made from what the card shows. While v matches, the API answers with Cache-Control: public, max-age=31536000, immutable, so a CDN can keep the image for a year. Edit the title and the page links a new URL. An outdated v still gets the current card, cached for an hour.

Cards are drawn only for what anyone may read. A draft, a hidden record, a record behind an access rule or an unknown member answers 404.

Before you begin

Set VITNODE_WEB_URL before you deploy

Social tags are absolute URLs. VitNode builds og:url and the site card's og:image from VITNODE_WEB_URL (the site card uses VITNODE_API_URL instead when it is set), and both fall back to http://localhost:3000. Nothing breaks on the page itself, so the first sign is a link preview with no picture: a crawler cannot open localhost.

In production set VITNODE_WEB_URL to the site's public origin, and VITNODE_API_URL to the API's when the API runs on its own. An app that serves its own API at /api needs only VITNODE_WEB_URL.

Set it where the server runs, not only in a local .env. On Cloudflare Workers that is vars in wrangler.jsonc:

wrangler.jsonc
{
  "vars": {
    "VITNODE_WEB_URL": "https://acme.example",
  },
}

On Docker, Vercel or a Node/Bun host, add it to the environment variables of the deployment. The browser bundle reads its copy at build time, so the build environment needs it too.

Check a deployed page with the curl command from Check the result: no og:image or og:url should start with http://localhost.

Change the colours and the site card

Add ogImage to the API config. The theme is merged over the defaults, and metadata.description appears under the title on the site card:

apps/api/src/vitnode.api.config.ts
export const vitNodeApiConfig = buildApiConfig({
  metadata: {
    title: "Acme Community",
    description: "Questions, answers and news for Acme makers.",
  },
  ogImage: {
    theme: { accent: "#16a34a", background: "#052e16" },
    version: "2",
  },
  // ...
});

Raise version whenever you change a template or the theme. It is part of every card URL, so crawlers and CDNs fetch the new cards instead of the cached ones.

Set ogImage.logo and every card shows it in the header. Pass SVG markup when you have it: it stays sharp at any size, and nothing is downloaded while a card is drawn. VitNode ships its own logo as VITNODE_LOGO_SVG (the full wordmark) and VITNODE_ICON_SVG (the hexagon alone):

apps/api/src/vitnode.api.config.ts
import { VITNODE_LOGO_SVG } from "@vitnode/api/lib/og-image/vitnode-logo";

export const vitNodeApiConfig = buildApiConfig({
  ogImage: {
    logo: { svg: VITNODE_LOGO_SVG, wordmark: true },
  },
  // ...
});
  • wordmark: true says the logo already spells the site name, so the card does not repeat the name beside it. Leave it out for a square icon, and the card shows the icon followed by metadata.title.
  • The root <svg> needs a viewBox (or width and height), which keeps the logo's proportions. The logo is drawn 56 px tall by default; set height to change it.
  • currentColor in the SVG is drawn in theme.foreground, so a logo whose text follows the page colour stays readable on a dark card. Use hex or rgb() colours inside the SVG.
  • A PNG, JPEG or WebP works too, as { src: "data:image/png;base64,...", size: { width, height } }. A remote URL is refused at startup, because cards are drawn without network access.

Changing the logo changes every card URL, so crawlers fetch the new cards.

Add a font for another script

The built-in Geist covers Latin, Latin Extended (Polish, Czech, Turkish...) and Cyrillic. For Greek, Arabic or CJK text, register a font that has those glyphs and put its family first in theme.fontFamily. VitNode never downloads fonts, so pass the bytes:

apps/api/src/vitnode.api.config.ts
import { readFileSync } from "node:fs";

export const vitNodeApiConfig = buildApiConfig({
  ogImage: {
    fonts: [
      {
        name: "Noto Sans",
        data: readFileSync("./fonts/NotoSans-Regular.ttf"),
        weight: 400,
      },
      {
        name: "Noto Sans",
        data: readFileSync("./fonts/NotoSans-Bold.ttf"),
        weight: 700,
      },
    ],
    theme: { fontFamily: "Noto Sans, VitNode Sans" },
  },
  // ...
});

TTF, OTF, WOFF and WOFF2 all work. Cloudflare Workers have no file system, so there you bundle the bytes into the code instead, for example as a base64 string. That is how VitNode ships Geist.

Draw your own cards

A plugin can register its own card template for its content types, an app can replace any card, and a page outside the Content Engine can serve a card from its own API route. See Social card templates.

Turn cards off

Set ogImage: { enabled: false } in the API config. Every card route then answers 404, and content metadata stops linking generated cards. Also set metadata.ogImage: false in src/vitnode.config.ts, or set it to the URL of a static image that every page without its own should use.

Check the result

Print a story's social tags, then fetch its card:

curl -s http://localhost:3000/stories/hello-content-engine | grep -oE '<meta [^>]*property="og:[^"]*"[^>]*>|<meta [^>]*name="twitter:card"[^>]*>'
<meta content="Hello Content Engine" property="og:title"/>
<meta content="article" property="og:type"/>
<meta content="http://localhost:3000/api/newsroom/content/stories/delivery/og/hello-content-engine?v=0k7ophq" property="og:image"/>
<meta content="summary_large_image" name="twitter:card"/>

The real output has more tags, and your v differs. Open the og:image URL in the browser to see the card. A 200 with Content-Type: image/png means it works. A 503 means the renderer failed, and the reason is in AdminCP → Debug Panel → Log explorer (/admin/core/debug).

Options reference

NameTypeDefaultDescription
enabledbooleantruefalse turns off every card route and generated og:image
fonts{ name, data, weight?, style? }[][]Fonts registered next to the built-in Geist (VitNode Sans)
logo{ svg } | { src, size }, plus height?, wordmark?-The site's logo in every card's header. See Add your logo
templateOgImageTemplateBuilt-in cardDraws every card a more specific template does not cover
templatesRecord<string, OgImageTemplate>{}Templates per content type id, over the plugins' ogImageTemplates
theme{ accent, background, foreground, muted, fontFamily }Dark card, blue accentMerged over the defaults
versionstring"1"Part of every card URL; raise it after changing a template or the theme