1. Static Metadata Export
Most layouts and pages define metadata by exporting ametadata
object. This object typically includes at least a title
and description
.
Example: app/layout.tsx
Example: app/main/layout.tsx
Example: app/(content)/blogs/page.tsx
Example: app/(content)/privacy-policy/page.tsx
2. Dynamic Metadata with generateMetadata
For dynamic routes, metadata can be generated at runtime using the generateMetadata
async function. This is useful for pages where the title, description, or OpenGraph data depend on fetched content.
Example: app/(content)/blogs/[id]/page.tsx
🔄 How to Change or Update Metadata
To update the metadata for any page or layout, simply edit themetadata
export or the generateMetadata
function in the corresponding file.
To update static metadata:
- Open the relevant file (e.g.,
app/layout.tsx
). - Edit the
metadata
object:
To update dynamic metadata:
- Open the file with a
generateMetadata
function (e.g.,app/(content)/blogs/[id]/page.tsx
). - Edit the logic or returned values as needed:
Note: Only fields and patterns already present in the codebase are supported. For more options, refer to the Next.js Metadata docs.