Create a small build script
Node 20 includes fetch, so the integration needs no HTTP dependency. This function sends the API key in a header, writes the returned PNG to the Eleventy output directory, and throws a readable error if the API rejects the request.
Collect the pages that deserve cards
Run the renderer from an Eleventy event after the content graph is available, or from a prebuild script that reads the same data files as the site. Exclude pagination helpers, tag archives, and utility pages unless they are meant to be shared. A deterministic filename based on fileSlug keeps each page URL stable across builds.
For a large site, keep a small manifest containing the render parameters and their hash. Skip the API call when the hash and output file already exist. ogshot also caches identical requests and does not count cache hits against the quota, but avoiding the network call makes local builds faster.
Publish the final static URL
Store the generated path in page data or derive it from the same slug in the base layout. Use an absolute URL for og:image and include width and height so validators can understand the asset without downloading it first.
Treat the content fields as the cache key
A change to title, author, theme, accent, logo, or template should regenerate the image. A body-copy change usually should not. Hash exactly those inputs so the build pipeline avoids stale cards without rerendering unrelated pages. When a design system changes globally, add a manual design version to every hash.
OGSHOT_API_KEY into an Eleventy data file that becomes public. Keep it in the CI environment and use it only from the Node build process.Inspect the deployed page
The generated PNG is only half of the integration. Deploy a page and run the public URL through the OG image checker. Confirm that the metadata URL is absolute, returns HTTP 200 with an image content type, is at least 1200×630, and remains legible in each platform crop.
Related guides: Hugo build-time cards, Astro content collections, and Bannerbear alternative comparison.