A Practical Metadata Strategy for Next.js Apps
How to structure static and dynamic metadata in App Router projects so SEO remains consistent as your app scales.
Why metadata architecture matters
Most teams start with metadata late, usually after a launch checklist flags missing tags. That approach works for a small site, but it becomes difficult to maintain when pages are generated from dynamic data.
Treat metadata as part of your route design. In App Router, each segment can contribute metadata, which makes it easier to keep titles and descriptions consistent without repeating logic.
Baseline metadata in root layout
The root layout should define defaults for:
- Site title template
- Base description
- Open Graph defaults
- Twitter card defaults
This gives every route a reliable fallback and avoids empty tags on new pages.
Dynamic metadata for detail routes
For content pages like /blog/[slug], use generateMetadata and derive fields from the content source.
The most common mistakes here are:
- Returning generic titles for every slug
- Forgetting canonical URLs
- Not matching Open Graph and page title
Keep metadata close to content
When posts live in MDX files, the simplest approach is exporting metadata from each file and consuming it in route helpers. This keeps authoring and SEO context in one place.
That means editors can update titles, descriptions, tags, and publish dates without touching route logic.
Final checklist
- Add defaults in root layout
- Add
generateMetadatafor dynamic routes - Generate sitemap and robots files
- Add JSON-LD for content pages
- Validate tags in production HTML output
If you treat metadata as first-class code from the beginning, SEO quality becomes a normal part of development instead of a release-time scramble.