SEO

Metadata helpers, automatic sitemap, JSON-LD structured data, and OG image generation.


Key files

  • lib/seo/metadata.ts - createMetadata() helper
  • lib/seo/routes.ts - Public routes for sitemap
  • lib/seo/jsonld.ts - JSON-LD builder functions
  • lib/seo/site.ts - Site-wide SEO defaults
  • components/seo/JsonLd.tsx - JSON-LD component
  • app/sitemap.ts - Auto-generated sitemap
  • app/robots.ts - Robots.txt configuration
  • app/opengraph-image.tsx - Default OG image

Environment variables

NEXT_PUBLIC_SITE_URL=https://yourdomain.com

Used for canonical URLs, sitemap, and OG images. Defaults to http://localhost:3001 in development.


Page metadata

Use the createMetadata helper for all public pages:

import { createMetadata } from "@/lib/seo/metadata";

export const metadata = createMetadata({
  title: "Pricing",
  description: "Simple, transparent pricing.",
  path: "/pricing",
});

The helper sets:

  • Title with site name template
  • Canonical URL
  • OpenGraph and Twitter cards
  • Default OG image

Sitemap

Register public routes in lib/seo/routes.ts:

export const publicRoutes: PublicRoute[] = [
  { path: "/", changeFrequency: "weekly", priority: 1.0 },
  { path: "/pricing", changeFrequency: "weekly", priority: 0.8 },
];

Protected routes are excluded via robots.txt.


JSON-LD structured data

Add structured data with the <JsonLd> component:

import { JsonLd } from "@/components/seo/JsonLd";
import { buildProductJsonLd, buildFaqJsonLd } from "@/lib/seo/jsonld";

// Product schema
<JsonLd data={buildProductJsonLd({
  name: "My Product",
  description: "Product description",
  brand: "My Brand"
})} />

// FAQ schema
<JsonLd data={buildFaqJsonLd({
  items: [
    { question: "What is this?", answer: "A great product." }
  ]
})} />

Available builders: buildProductJsonLd, buildFaqJsonLd, buildArticleJsonLd, buildBreadcrumbsJsonLd


OG images

Default OG image is auto-generated at /opengraph-image. Customize by editing app/opengraph-image.tsx.

For per-page OG images, create opengraph-image.tsx in the page's folder.


Audit a page

Use the /seo-audit-page Cursor command to check and fix SEO issues on any page.