Chapter 2

Rendering

How OpenGraph+ captures your pages

When a social platform requests your page’s og:image, OpenGraph+ loads your page in a headless browser and captures it as an image.

The render process

  1. Social platform (LinkedIn, Twitter, etc.) requests your page
  2. Your server returns HTML with og:image pointing to OpenGraph+
  3. Platform fetches the image URL
  4. OpenGraph+ loads your page in a headless browser
  5. OpenGraph+ injects data-ogplus on <html>
  6. OpenGraph+ checks for templates or applies CSS styling
  7. OpenGraph+ captures the viewport as an image
  8. Image is returned to the social platform

The data attribute

When rendering, OpenGraph+ adds data-ogplus to your <html> element:

<!-- Generic render -->
<html data-ogplus>

<!-- Platform-specific render -->
<html data-ogplus="linkedin">
<html data-ogplus="twitter">

This attribute is your hook for styling. Any CSS that targets [data-ogplus] only applies during social card rendering—not to regular visitors.

Rendering modes

OpenGraph+ supports three rendering modes, checked in this order:

  1. Templates — Custom layouts using <template id="ogplus"> elements. See Templates.
  2. Selector isolation — Extract a specific element using og:plus:selector meta tag.
  3. Full page — Render the entire viewport with CSS styling via data-ogplus.

Meta tags reference

Control rendering behavior directly in your HTML with meta tags.

Meta tag Description
og:plus:viewport:width Viewport width in pixels
og:plus:selector CSS selector to isolate
og:plus:style Inline CSS for body
og:plus:cache:max_age Cache TTL in seconds
og:plus:cache:etag Cache version identifier

Viewport width

Override the viewport width for this page:

<meta property="og:plus:viewport:width" content="800">

Mobile widths (600-800px) tend to work best for social cards since they force a simpler, more focused layout.

Selector

Capture only a specific element instead of the full viewport:

<meta property="og:plus:selector" content="#social-card">

If the selector matches a <template> element, OpenGraph+ treats it as a template (evaluating ${...} expressions). Otherwise, it clones the element and places it directly in <body> before capturing. Cloned elements may have rendering issues if they rely on inherited styles from parent elements or CSS that uses descendant selectors.

Style

Inject inline styles during rendering:

<meta property="og:plus:style" content="background: white; padding: 40px;">

These styles apply to the <body> element during capture. Use this for quick adjustments without modifying your CSS.

Cache max age

Set how long the rendered image stays fresh (in seconds):

<meta property="og:plus:cache:max_age" content="86400">

This overrides HTTP Cache-Control headers. See HTTP Caching for details.

Cache etag

Set a version identifier for cache invalidation:

<meta property="og:plus:cache:etag" content="v1.2.3">

When the etag changes, OpenGraph+ re-renders even if the cache hasn’t expired. See HTTP Caching for details.

Example

Combine meta tags to fully control rendering:

<head>
  <meta property="og:plus:viewport:width" content="800">
  <meta property="og:plus:selector" content=".blog-hero">
  <meta property="og:plus:style" content="padding: 20px;">
  <meta property="og:plus:cache:max_age" content="86400">
</head>

This renders at 800px wide, extracts the .blog-hero element, adds padding around it, and caches the result for 24 hours.