# Dynamic routes use generateMetadata for OG tags

- **Pattern:** `ab-001820` (`marketing-social-sharing.share-infrastructure.dynamic-og-for-dynamic-content`)
- **Severity:** critical
- **Lifecycle:** active
- **Last modified:** 2026-04-18
- **Canonical URL:** https://auditbuffet.com/patterns/ab-001820
- **License:** CC-BY-4.0 — attribute to AuditBuffet Pattern Catalog (https://auditbuffet.com/patterns/ab-001820)

## Why it matters

A static `metadata` export on a dynamic route (`[slug]`, `[id]`, `[username]`) applies identical OG tags to every instance of that route. Every blog post shares the same title, every product page shows the same description, and every user profile presents the same image in social previews. Per ogp.me, og tags are the mechanism social platforms use to generate link preview cards; when all instances of a dynamic route return the same tags, the platform cannot differentiate between content pieces. This is the most common and highest-impact social sharing gap in AI-built projects: content that was individually created gets collectively presented as one undifferentiated link, eliminating per-content shareability entirely.

## Severity rationale

Critical because static metadata on dynamic routes makes every instance of that route present identically in social feeds, eliminating the individual shareability of each piece of content.

## Remediation

Replace static `metadata` exports on dynamic routes with `generateMetadata` functions that fetch the specific item and build OG tags from its data:

```ts
// app/blog/[slug]/page.tsx
// WRONG:
export const metadata: Metadata = { openGraph: { title: 'My Blog' } }

// RIGHT:
export async function generateMetadata({ params }: { params: { slug: string } }): Promise<Metadata> {
  const post = await getPostBySlug(params.slug)
  if (!post) return { title: 'Not Found' }
  return {
    openGraph: {
      title: post.title,
      description: post.excerpt,
      images: [{ url: post.ogImageUrl ?? '/og-default.png', width: 1200, height: 630 }],
      url: `https://yoursite.com/blog/${params.slug}`,
    },
  }
}
```

Apply this pattern to every `[param]` route directory in `app/` that renders public-facing content.

## Detection

**The detection method for this pattern is part of AuditBuffet Pro.**

The full method (what to look for, pass and fail conditions, and how results get reported) ships inside the [Social Sharing Audit](https://auditbuffet.com/audits/marketing-social-sharing). The pattern definition, severity rationale, and remediation remain openly licensed under CC-BY-4.0.

## External references

- external ogp.me — https://ogp.me/

Taxons: findability

HTML version: https://auditbuffet.com/patterns/ab-001820
