{"success":true,"name":"use-the-next-js-metadata-api-for-titles-and-seo-tags","description":"Adding page titles, descriptions, or social tags in Next.js","category":"ai-brimind","path":"ai-brimind/use-the-next-js-metadata-api-for-titles-and-seo-tags/SKILL.md","file":"SKILL.md","content":"---\nname: use-the-next-js-metadata-api-for-titles-and-seo-tags\ndescription: \"Adding page titles, descriptions, or social tags in Next.js\"\n---\n\n# Use the Next.js Metadata API for Titles and SEO Tags\n\n## When to use\nProject is Next.js App Router, and you are about to write manual <head>/<title> tags or install an SEO package for basic meta.\n\n## Example request\nhardcoding <title> inside the component JSX → the App Router ignores hand-placed head tags; export const metadata is the mechanism. — Built-in metadata export. | product page needs a title from fetched data → generateMetadata is the async version made exactly for that. — Dynamic metadata function. | every page repeats the site name manually → the root layout metadata sets a title template like '%s | MySite' once. — Template inheritance. | installing an SEO library to set og:image and description → the built-in Metadata API already covers Open Graph, Twitter cards, and canonical. — Reuse before dependency.\n\n## Instructions\nAct like a developer who checks what the framework already provides before writing a single head tag. When a Next.js App Router page needs titles, descriptions, or social previews: 1) Use the built-in mechanism: export const metadata for static values, and an async generateMetadata({ params }) when the values come from fetched data (product name, article title). Never place raw <title> or <meta> tags in component JSX — the App Router does not manage those. 2) Set shared patterns once at the top: the root layout defines the title template ('%s | SiteName'), default description, and default social image; child pages then supply only their specific part. Repeating the site name per page is the smell that the template is missing. 3) Before adding an SEO package, list what the Metadata API already covers — title, description, Open Graph, Twitter cards, canonical, robots, icons — and justify in one line what the package adds beyond that. Most basic needs require zero dependencies. 4) For dynamic pages, make sure generateMetadata and the page share fetched data through fetch deduplication or a cached function, instead of writing two different queries that can disagree. 5) If unsure what a specific tag should contain, check how the page should look when shared in a chat or listed in search, and work backward. Only add metadata once the static/dynamic split is decided, and explain why each value lives at its level (layout template vs page-specific) — not just that a title shows up in the tab.\n\n## Metadata\n- role: developer\n- level: tactical\n- places: vibeCoding\n- origin: ai.brimind.pro skill #506\n","linked_files":[],"origin":"ai.brimind.pro","owner_id":null,"source":"router"}