Hire Laravel developers with AI expertise at $20/hr. Get started in 48 hours.

OG Kit: Generate Dynamic Open Graph Images with HTML and CSS

Published on by

OG Kit is a service for generating dynamic Open Graph images using your own HTML and CSS. Created by Peter Suhm, it lets you define OG image templates directly in your codebase instead of relying on external design tools or headless browser setups.

How It Works

You add a <template> tag with your OG image markup to any page on your site, include the OG Kit client script, and the service handles rendering and caching the images. To preview a template in your browser, append ?ogkit-render to any URL and use your browser's dev tools to tweak it live.

<template data-og-template>
<div style="width: 1200px; height: 630px; display: flex; align-items: center; justify-content: center;">
<h1>{{ $post->title }}</h1>
</div>
</template>
<script src="https://cdn.jsdelivr.net/npm/ogkit@1"></script>

Because templates are standard HTML and CSS, you can use your existing styles, fonts, images, and templating language. There is no custom DSL to learn.

Laravel Integration

OG Kit provides an official Laravel package that supports Laravel 10, 11, and 12:

composer require petersuhm/ogkit-laravel

The package auto-discovers its service provider, so no additional setup is needed beyond installation.

Then, you can use a template like this:

<body>
<article>
<h1>{{ $post->title }}</h1>
<p>{{ $post->excerpt }}</p>
</article>
 
@ogTemplate
<div class="w-full h-full bg-slate-900 text-white p-16 flex flex-col justify-end">
<p class="text-xl opacity-80">{{ config('app.name') }}</p>
<h1 class="mt-6 text-6xl font-bold">{{ $post->title }}</h1>
<p class="mt-4 text-2xl">{{ $post->excerpt }}</p>
</div>
@endOgTemplate
</body>

This also works with Inertia, and you can view all the docs on the Laravel integration here.

Pricing

OG Kit offers a free tier with 25 pages, with paid plans starting at $99/year for 1,000 pages. All plans include cached images and unlimited domains. A "page" represents a unique URL where OG Kit generates and hosts an OG image.

Plan Price Pages
Free $0 25 pages
Basic $99/year 1,000 pages
Pro $299/year 10,000 pages
Custom Contact sales Higher limits

For more details, visit the OG Kit website or check out the Laravel package on GitHub.

Eric L. Barnes photo

Eric is the creator of Laravel News and has been covering Laravel since 2012.

Cube

Laravel Newsletter

Join 40k+ other developers and never miss out on new tips, tutorials, and more.

image
Laravel Code Review

Get expert guidance in a few days with a Laravel code review

Visit Laravel Code Review
SerpApi logo

SerpApi

Access real-time search engine results through a simple API—no more scraping headaches! Use it for AI applications, SEO tools, product research, travel information, and more

SerpApi
Kirschbaum logo

Kirschbaum

Providing innovation and stability to ensure your web application succeeds.

Kirschbaum
Lucky Media logo

Lucky Media

Get Lucky Now - the ideal choice for Laravel Development, with over a decade of experience!

Lucky Media
PhpStorm logo

PhpStorm

The go-to PHP IDE with extensive out-of-the-box support for Laravel and its ecosystem.

PhpStorm
Tinkerwell logo

Tinkerwell

The must-have code runner for Laravel developers. Tinker with AI, autocompletion and instant feedback on local and production environments.

Tinkerwell
Laravel Cloud logo

Laravel Cloud

Easily create and manage your servers and deploy your Laravel applications in seconds.

Laravel Cloud
Get expert guidance in a few days with a Laravel code review logo

Get expert guidance in a few days with a Laravel code review

Expert code review! Get clear, practical feedback from two Laravel devs with 10+ years of experience helping teams build better apps.

Get expert guidance in a few days with a Laravel code review
Shift logo

Shift

Running an old Laravel version? Instant, automated Laravel upgrades and code modernization to keep your applications fresh.

Shift
Acquaint Softtech logo

Acquaint Softtech

Acquaint Softtech offers AI-ready Laravel developers who onboard in 48 hours at $3000/Month with no lengthy sales process and a 100 percent money-back guarantee.

Acquaint Softtech
SaaSykit: Laravel SaaS Starter Kit logo

SaaSykit: Laravel SaaS Starter Kit

SaaSykit is a Multi-tenant Laravel SaaS Starter Kit that comes with all features required to run a modern SaaS. Payments, Beautiful Checkout, Admin Panel, User dashboard, Auth, Ready Components, Stats, Blog, Docs and more.

SaaSykit: Laravel SaaS Starter Kit
Harpoon: Next generation time tracking and invoicing logo

Harpoon: Next generation time tracking and invoicing

The next generation time-tracking and billing software that helps your agency plan and forecast a profitable future.

Harpoon: Next generation time tracking and invoicing

The latest

View all →
Laravel Installer Now Returns JSON When Running Inside an AI Agent image

Laravel Installer Now Returns JSON When Running Inside an AI Agent

Read article
Queue-Wide Inspection Methods in Laravel 13.8.0 image

Queue-Wide Inspection Methods in Laravel 13.8.0

Read article
Verifiable Audit Logging with Laravel Chronicle image

Verifiable Audit Logging with Laravel Chronicle

Read article
Ship AI with Laravel: Search Entire PDFs with Zero Search Logic image

Ship AI with Laravel: Search Entire PDFs with Zero Search Logic

Read article
Personalized Content Delivery System: Building an AI-powered recommendation engine with Laravel and MongoDB image

Personalized Content Delivery System: Building an AI-powered recommendation engine with Laravel and MongoDB

Read article
Laravel Brain: Visualize Your Application's Request Lifecycle image

Laravel Brain: Visualize Your Application's Request Lifecycle

Read article