Metadata in layouts
📖 Scenario: You are building a simple Next.js website with a consistent layout. You want to add metadata like the page title and description that applies to all pages using a layout component.
🎯 Goal: Create a Next.js layout component that defines metadata for the entire site using the metadata export. This metadata should include a title and description. Then use this layout in your app.
📋 What You'll Learn
Create a layout component file named
layout.js in the app directoryAdd a
metadata export object with title and description propertiesUse the
children prop to render nested page content inside the layoutExport the layout component as default
💡 Why This Matters
🌍 Real World
Websites often need consistent metadata for SEO and social sharing. Using layouts to define metadata helps keep it organized and reusable.
💼 Career
Understanding Next.js layouts and metadata is important for frontend developers working on modern React-based web applications.
Progress0 / 4 steps