ScreenshotNeo

BlogGuides

What Does Social Image Mean in Web Development?

A social image is the preview picture attached to a shared URL. Learn how og:image works, choose dimensions, generate images, and fix missing previews.

By the ScreenshotNeo team1 October 20268 min read

A social image is the picture shown in a link preview when someone shares a webpage on a social network or messaging app. It is usually selected with the Open Graph og:image metadata tag. The image is part of a larger preview card that can also contain the page title, description, content type, and canonical URL.

A social image is metadata-driven. It is different from an ordinary <img> displayed in the page body: a crawler reads the document head, fetches the declared image URL, and builds the preview card.

1. How a social image works

The Open Graph protocol defines a webpage as a rich object in a social graph. Its four required properties are og:title, og:type, og:image, and og:url. The og:image value is the URL of the image representing the shared page. See the Open Graph protocol specification.

  1. A user shares a page URL.
  2. The platform’s crawler requests the page.
  3. The crawler reads metadata in the document’s <head>.
  4. It downloads the og:image asset.
  5. The platform combines that asset with the title, description, and URL to render a preview.

If the metadata is missing, malformed, blocked, or cached, the platform may show a blank card, an unrelated page image, or an old image.

2. Add the metadata to an HTML page

Put these tags in the rendered document head. The image URL must be absolute and use HTTPS.

<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <title>Example article</title>

  <meta property="og:title" content="Example article title">
  <meta property="og:description" content="Short explanation of the page">
  <meta property="og:type" content="article">
  <meta property="og:url" content="https://example.com/articles/example">
  <meta property="og:image" content="https://example.com/images/example-share.jpg">
  <meta property="og:image:alt" content="Description of the social image">
  <meta property="og:image:width" content="1200">
  <meta property="og:image:height" content="630">

  <meta name="twitter:card" content="summary_large_image">
</head>
<body>
  <article>...</article>
</body>
</html>

The twitter:card tag requests a large-image card on services that support Twitter card metadata. Keep og:url aligned with the canonical URL of the page being shared.

Tag Purpose Typical value
og:title Preview headline The page title
og:description Preview summary A short explanation
og:type Object type article, website, or another supported type
og:url Canonical shared URL Absolute HTTPS page URL
og:image Social image URL Absolute HTTPS PNG, JPEG, or WebP URL
og:image:alt Accessible image description Short description of the visual
og:image:width Declared width 1200
og:image:height Declared height 630

You can provide multiple og:image tags. Platforms generally consider them in priority order, so put the preferred image first.

3. Choose dimensions and a file format

A practical general-purpose starting size is 1200 × 630 pixels, approximately a 1.91:1 ratio. The OG Image Design size guide recommends this size for broad compatibility.

  • Use PNG, JPEG, or WebP.
  • Keep the image reachable without authentication.
  • Declare dimensions when you know them.
  • Leave a central safe area because services can crop differently.
  • Use a stable URL, or deliberately version the URL when publishing a replacement.

There is no single crop that every platform displays identically. Preview the image in the target service and keep headlines, logos, and other essential elements away from the extreme edges.

4. Design a social image that survives cropping

Use strong contrast between the foreground and background. Make the main subject understandable without surrounding page context. Keep text large enough to remain legible in a small card, and place it near the center. Do not rely on tiny details at the top or bottom edges.

Approach Consistency Per-page personalization Maintenance
Hand-designed image High editorial control Low to medium New asset for each page
Generated image Consistent template High Requires a generation pipeline
One shared image Simple Low Lowest ongoing work
Platform-specific variants Best crop control High More files and metadata to maintain

5. Generate images for pages automatically

Automatic generation is useful when every article needs its own title, author, category, or product name. The generated image still needs a stable, publicly reachable URL and an og:image tag pointing to it.

Next.js supports route-based image files through the opengraph-image and twitter-image conventions. Its documentation explains how these files become social images for a route: Next.js Open Graph image conventions.

// app/blog/[slug]/opengraph-image.tsx
import { ImageResponse } from 'next/og'

export const runtime = 'edge'

export default async function Image({ params }: { params: { slug: string } }) {
  const title = params.slug.replaceAll('-', ' ')

  return new ImageResponse(
    (
      <div
        style={{
          width: '100%',
          height: '100%',
          display: 'flex',
          alignItems: 'center',
          justifyContent: 'center',
          background: '#111827',
          color: 'white',
          fontSize: 64,
          padding: 80,
        }}
      >
        {title}
      </div>
    ),
    { width: 1200, height: 630 }
  )
}

In production, derive the title from your content record rather than formatting the slug. Escape untrusted text, handle missing records, and make sure the route returns an image before adding its URL to metadata.

6. Validate a social image before publishing

  1. Inspect the rendered HTML in a browser or with an HTTP client. Confirm that og:image is present in the final response, not just in a source template.
  2. Open the image URL directly. Confirm that it returns a supported raster image, uses HTTPS, and does not require a login, cookie, or special header.
  3. Check the dimensions, file size, and central safe area.
  4. Verify that og:url matches the canonical page being shared.
  5. Use the target platform’s preview debugger or validator.
  6. Test after changing the image URL or query string if the platform is still displaying a cached result.

7. Troubleshooting missing or incorrect previews

Symptom Likely cause Fix
No image appears Missing og:image, relative URL, or crawler cannot fetch it Add an absolute HTTPS URL and test it without authentication
Old image remains Sharing service cached the previous metadata or asset Use the platform debugger and publish a versioned image URL when appropriate
Wrong page image appears Metadata is absent from rendered HTML or another image is being selected Inspect the final HTML and put the preferred og:image first
Image is cropped badly Important content is near an edge or the platform uses a different ratio Move essential content toward the center and preview the target service
Image request fails Redirect loop, authorization, robots policy, timeout, or server error Serve a direct, fast, public raster file and inspect the response status
Preview title or URL is wrong Conflicting or stale og:title or og:url Keep one canonical set of tags aligned with the page
Generated image is blank Generation route throws, lacks data, or returns the wrong content type Log generation failures, handle missing data, and verify the response directly

8. Performance, reliability, and cost considerations

  • Performance: serve the image from a cacheable asset host and avoid generating a new image during every crawler request unless the result is cached.
  • Reliability: keep a fallback image for pages with missing content data. A stable image URL reduces failures caused by dynamic generation.
  • Cache behavior: crawlers and sharing platforms can retain old metadata. A changed filename or query string can help identify a new version, subject to the platform’s own cache rules.
  • Security: never put secrets in image URLs or generated text. Treat route parameters and article data as untrusted input.
  • Cost: hand-designed assets have editorial labor costs; generated assets consume build or runtime resources. Choose one shared template, per-page generation, or platform-specific variants based on how much personalization you need.

9. Capture a reliable social image from a rendered page

If the social image should reproduce a live page, a browser must render CSS, fonts, images, and JavaScript before capture. A typical do-it-yourself workflow is:

  1. Launch a headless browser.
  2. Set a fixed viewport and device scale factor.
  3. Navigate to the page and wait for the key content or network idle.
  4. Hide cookie banners, chat widgets, and other overlays.
  5. Capture the full page or a selected element.
  6. Resize or convert the result to a 1200 × 630 social asset.
  7. Upload the asset to a public HTTPS URL and set og:image to that URL.
import { chromium } from 'playwright'

const browser = await chromium.launch()
const page = await browser.newPage({ viewport: { width: 1200, height: 630 }, deviceScaleFactor: 1 })
await page.goto('https://example.com/article', { waitUntil: 'networkidle' })
await page.screenshot({ path: 'social-image.png', fullPage: false })
await browser.close()

For full-page screenshots, use fullPage: true. For one component, locate it and call its screenshot method. In either case, check that lazy-loaded images have appeared and that overlays have not covered the content.

10. Or skip the browser setup

ScreenshotNeo provides a website screenshot API and MCP server. One GET request returns a PNG, JPEG, WebP, or PDF. Its capture options include full-page screenshots with lazy images loaded, CSS-element capture, dark mode, device presets or custom viewports, retina scale, custom CSS and JavaScript, clicks, waits, blocked requests, headers, cookies, user agents, timezone, geolocation, transparent backgrounds, resizing, caching, signed links, asynchronous jobs, bulk capture, and a usage API. See the ScreenshotNeo API documentation.

curl -G "https://api.screenshotneo.com/v1/shot" \
  -d access_key=YOUR_API_KEY \
  --data-urlencode url=https://example.com/article \
  -o social-image.webp
import requests

r = requests.get(
    "https://api.screenshotneo.com/v1/shot",
    params={"access_key": "YOUR_API_KEY", "url": "https://example.com/article"},
    timeout=90,
)
r.raise_for_status()
open("social-image.webp", "wb").write(r.content)
const q = new URLSearchParams({
  access_key: 'YOUR_API_KEY',
  url: 'https://example.com/article'
})
const res = await fetch(`https://api.screenshotneo.com/v1/shot?${q}`)
if (!res.ok) throw new Error(`Screenshot failed: ${res.status}`)
const image = Buffer.from(await res.arrayBuffer())
await import('node:fs/promises').then(fs => fs.writeFile('social-image.webp', image))

ScreenshotNeo accepts the cookie or consent banner like a visitor and removes more than 60 known consent platforms, newsletter popups, and chat widgets before capture; each step can be turned off. Bot checks or CAPTCHAs, blank pages, timeouts, failed loads, and cache hits cost nothing, and the response identifies the result with X-Page-Verdict and X-Billed headers. Its MCP server provides take_screenshot, get_page_info, and capture_pdf tools for Claude, Cursor, and other MCP clients.

The Free plan includes 1,000 shots per month with no card. Paid plans start at $5 for 3,000 shots; yearly billing gives two months free, and every feature is available on every plan. Create a free ScreenshotNeo account.

11. FAQ

Is a social image the same as a favicon?

No. A favicon identifies a site or browser tab. A social image represents a shared page in a link preview.

Do I need an <img> tag in the page body?

No. The preview image is normally declared in the document head with og:image. You can also display the same asset in the page body if it helps readers, but that is separate.

Can I use a relative image URL?

Use an absolute HTTPS URL. Relative paths commonly fail because crawlers do not resolve them consistently across implementations.

Should every article have a unique social image?

Unique images improve page-level relevance, while one shared image is easier to maintain. Generated route images are a practical middle ground.

Why does a validator show the new image while a real message still shows the old one?

The messaging service may have cached the previous metadata or asset. Wait for its cache to expire, use its refresh tool when available, or publish a versioned image URL.

What is the safest default image size?

Start with 1200 × 630 pixels, then preview it on the services that matter to your audience.