OpenGraph templates: design the share image for your pages
Describes OpenGraph 0.4.0.
An OpenGraph template is the design of the picture that appears when a page from your site is shared on Facebook, X, LinkedIn, Discord or Slack. You lay it out once, with placeholders for things like the post title, and the site draws a fresh image for each page.
Where to find it
In the admin sidebar, open OpenGraph, then Templates (/admin/open-graph). You need a role with the OpenGraph permission. The OpenGraph module must be enabled on the Modules page.
OpenGraph templates: the designs for share images, none yet.
The templates list
OpenGraph templates lists every template by name, with its description when it has one. Click a template to open it in the editor.
- New template creates a template named “Untitled 1” (or the next free number) and opens the editor.
- The red trash icon deletes a template after you confirm. When assignments use it, the confirmation says how many, and they are removed with it. A page whose assignment goes this way falls back to the next assignment that applies, or to its own image.
Go to assignments → at the bottom leads to the Assignments page, where you decide which pages use which template.
The editor
Every card is 1200 × 630 pixels, the usual size for share images.
Toolbar
- The back arrow returns to the list.
- The name field renames the template as you type. Names must be unique.
- Insert… adds an element (see below).
- With an element selected: Bring to front, Send to back and Delete element.
- Save saves at once. A badge shows Saved, Unsaved… or Save failed.
Changes save on their own a moment after each edit; Ctrl+S saves immediately.
Adding elements
Insert… offers:
- Static text: text you type.
- Text variable: a numbered placeholder (
{{TextN}}) filled in per page. - Static image: a picture from the media library.
- Image variable: a numbered image placeholder (
{{ImageN}}) filled in per page. - Rectangle: a solid shape with rounded corners.
- Call-to-action button: a button that sizes itself to its label.
- Stamp: a short badge or label.
- Site globals: Site URL, Site host, Site name, Current page URL and Current locale. These fill themselves in, with no setup.
You can also type a placeholder into any text: {{name}} for a value wired up per page, [[site_name]] and the other globals for site values.
Moving and arranging
Drag an element to move it, drag its corner handles to resize, and press Delete to remove it. The arrow keys nudge the selection by one pixel, or ten with Shift.
Preview frames
The tabs above the stage show the card inside a mock of Card, Facebook, X (Twitter), LinkedIn or Discord / Slack, with a sample title and description. You keep editing inside the frame.
Raw variables switches the stage to show the placeholders as tokens; Sample values switches back to stand-in text (“Sample” and the slot name) and a placeholder image.
The right-hand panel
Slots used lists every placeholder the template declares so far. These are what you wire to real data on the Assignments page.
With nothing selected, the panel shows the Template settings: the Background as a Color, an Image (with Fit: Fill, Contain or Stretch) or a Gradient (From, To and Angle).
With an element selected, it shows Position & size (X, Y, Width, Height) and the element’s own settings:
- Text: Content (or Variable name for a text variable), Size, Weight, Color, Align (Left, Center, Right) and Legibility underlay, a backing behind the text whose strength you set in percent.
- Image: Source as Constant (a media file) or Variable (a Variable name: letters, digits and underscores only), Fit, Corner radius and Fade edge, which fades the picture toward Left, Right, Top or Bottom.
- Rectangle: Fill and Corner radius.
- Button: Label (type
{{cta}}to make it a placeholder), Style (Solid, Outline, Soft), Fill, Text, Text size, Radius and Auto-width, which lets the button grow with a translated label.
Anchor to pins an element below or above another one, with a Gap. When the other element grows, for example a title that wraps onto two lines, the anchored element moves with it. Nothing (fixed position) unpins it.
What it doesn’t do
- A template does nothing by itself. It is used only once it is assigned on the Assignments page.
- The card size is fixed at 1200 × 630.
- The editor has no field for the description shown on the list.
- The editor needs JavaScript.
For developers
- Images are drawn to PNG with the bundled
resvglibrary. If it can’t load on your server, install theresvgcommand line tool,rsvg-convertor ImageMagick. If drawing fails, the page keeps its own share image. - Rendered images are cached and served publicly at
/og-image/<key>.