← Next.js learning path
Next.js · Module 7 of 10

SEO and metadata

Give each page titles, descriptions, social cards and sitemaps.

📖 Key ideas

  1. Export metadata = { title, description } from a page or layout.
  2. generateMetadata creates metadata for dynamic pages.
  3. Add Open Graph images for social sharing.
  4. app/sitemap.ts and app/robots.ts generate SEO files.
  5. Use semantic HTML and one h1 per page.
💡 Real-life example: Metadata is the label on a jar: search engines read it before opening.
metadataExported object for title and description
generateMetadataAsync metadata for dynamic routes
Open GraphTags for social previews
sitemap.tsGenerates sitemap.xml