Dynamic Metadata
Setting up SEO and metadata using helper functions.
Dynamic Metadata Setup
StarterKitPro comes pre-configured with a robust dynamic metadata system that works seamlessly across key areas:
- Layouts
- Landing Page
- Blog Pages (both list and individual posts)
- Documentation Pages
Setting up metadata for any newly created pages is also straightforward using the provided helper functions. This section explains how the system is implemented.
StarterKitPro utilizes helper functions located in lib/seo/metadata.ts
to simplify setting up SEO metadata and viewport settings across your application, leveraging Next.js 15's file-based metadata capabilities.
Metadata (constructMetadata
)
The constructMetadata
function generates a comprehensive Metadata
object for individual pages. It automatically includes:
- Default
title
,description
,keywords
, andapplicationName
fromapp-config.ts
. - Default Open Graph and Twitter card tags, automatically using
/app/opengraph-image.png
and/app/twitter-image.png
if they exist. - A
metadataBase
set according to yourdomainName
and environment.
Usage:
Import and export metadata
from your page.tsx
files using this helper.
Recommendation
While many tags default correctly, it's highly recommended to set a
specific title
and canonicalUrlRelative
for each page to improve SEO
clarity.
Available Parameters:
You can override the defaults by passing an object with the following optional properties to constructMetadata
:
Global Viewport Settings (getViewportMetadata
)
The getViewportMetadata
function generates the standard viewport configuration recommended for responsive web design.
Usage:
This is typically exported once from your root layout file (/app/layout.tsx
) to apply globally.
This ensures consistent viewport behavior across all pages of your application.