Try Depot: Bring ultra-fast, remote Docker builds directly to your Laravel workflow

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
Jump24 - UK Laravel Agency

Laravel Developers that Click into Place. Never outsourced. Never offshored. Always exceptional.

Visit Jump24 - UK Laravel Agency
Tinkerwell logo

Tinkerwell

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

Tinkerwell
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
PhpStorm logo

PhpStorm

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

PhpStorm
Laravel Cloud logo

Laravel Cloud

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

Laravel Cloud
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
Kirschbaum logo

Kirschbaum

Providing innovation and stability to ensure your web application succeeds.

Kirschbaum
Shift logo

Shift

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

Shift
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
Lucky Media logo

Lucky Media

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

Lucky Media
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

The latest

View all →
Prism Workers AI — A Cloudflare Workers AI Provider for Prism PHP image

Prism Workers AI — A Cloudflare Workers AI Provider for Prism PHP

Read article
Take the Pain Out of Data Imports with Laravel Ingest image

Take the Pain Out of Data Imports with Laravel Ingest

Read article
Liminal: A Browser-Based IDE for Laravel Powered by WebAssembly image

Liminal: A Browser-Based IDE for Laravel Powered by WebAssembly

Read article
NativePHP v3.1: The Biggest Performance Leap Yet image

NativePHP v3.1: The Biggest Performance Leap Yet

Read article
Prompt Deck: Manage AI Prompts as Versioned Files in Laravel image

Prompt Deck: Manage AI Prompts as Versioned Files in Laravel

Read article
Laravel Prompts v0.3.15 Adds Streaming, Tasks, Autocomplete, and More image

Laravel Prompts v0.3.15 Adds Streaming, Tasks, Autocomplete, and More

Read article