SEO
Metadata helpers, automatic sitemap, JSON-LD structured data, and OG image generation.
Key files
lib/seo/metadata.ts-createMetadata()helperlib/seo/routes.ts- Public routes for sitemaplib/seo/jsonld.ts- JSON-LD builder functionslib/seo/site.ts- Site-wide SEO defaultscomponents/seo/JsonLd.tsx- JSON-LD componentapp/sitemap.ts- Auto-generated sitemapapp/robots.ts- Robots.txt configurationapp/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.