Configure OG Pilot credentials
Set OG_PILOT_API_KEY and OG_PILOT_DOMAIN in Astro server env vars.
Generate signed OG image URLs in Astro server context and render them in your layout metadata.
Set OG_PILOT_API_KEY and OG_PILOT_DOMAIN in Astro server env vars.
Generate OG image URLs in server code using page-level data.
Set og:image and twitter:image tags in your Astro layout template.
Use platform debuggers to refresh caches after publishing.
// src/lib/og-image.ts
import { configure, createImage } from "og-pilot-js"
configure((config) => {
config.apiKey = import.meta.env.OG_PILOT_API_KEY
config.domain = import.meta.env.OG_PILOT_DOMAIN
})
export async function ogImageForPage(data: {
title: string
description: string
path: string
}) {
return createImage(
{
template: "page",
title: data.title,
description: data.description,
path: data.path,
},
{ iat: Math.floor(Date.now() / 1000) },
)
}
---
// src/layouts/BaseLayout.astro
import { ogImageForPage } from "../lib/og-image"
const ogImage = await ogImageForPage({
title: Astro.props.title,
description: Astro.props.description,
path: Astro.url.pathname,
})
---
<meta property="og:image" content={ogImage} />
<meta name="twitter:card" content="summary_large_image" />
<meta name="twitter:image" content={ogImage} />Yes. Generate URLs at build-time or in server-rendered routes depending on your setup.
Yes. Send template-specific payload fields for blog, product, event, and more.
OG Pilot turns page metadata into consistent, high-quality social previews without manual design exports.