Skip to content

Install on Next.js (App Router)

Return the card URL from generateMetadata on every page that should get a card. The path is the page's own path on your verified domain.

// lib/og-card.ts
export function ogCard(path: string) {
  const url = new URL('/v1/og/YOUR_SITE_ID', 'https://linkmag.net')
  url.searchParams.set('path', path)
  return url.toString()
}
// app/blog/[slug]/page.tsx
import type { Metadata } from 'next'
import { ogCard } from '@/lib/og-card'

export async function generateMetadata({
  params
}: {
  params: Promise<{ slug: string }>
}): Promise<Metadata> {
  const { slug } = await params
  const image = ogCard(`/blog/${slug}`)
  return {
    openGraph: { images: [{ url: image, width: 1200, height: 630 }] },
    twitter: { card: 'summary_large_image', images: [image] }
  }
}

Remove any opengraph-image file in the same route segment: Next.js prefers it over generateMetadata images.

Agents can request any page on this site as markdown by sending Accept: text/markdown.