GenerateMetadata for dynamic metadata
📖 Scenario: You are building a blog website using Next.js. Each blog post page should have its own unique title and description that changes based on the post content.
🎯 Goal: Create a dynamic generateMetadata function in a Next.js page that sets the page title and description based on the blog post data.
📋 What You'll Learn
Create a simple blog post data object with
title and description fieldsAdd a config variable for the site name
Write a
generateMetadata function that returns metadata using the blog post data and site nameExport the
generateMetadata function from the page file💡 Why This Matters
🌍 Real World
Dynamic metadata improves SEO and user experience by showing relevant titles and descriptions for each page.
💼 Career
Understanding Next.js dynamic metadata is important for frontend developers working on modern React frameworks and SEO optimization.
Progress0 / 4 steps