Static Metadata

The metadata Export

Export a metadata object from a layout or page. Next.js renders the <title> and <meta> tags in <head>. Child pages override or extend parent values.

// app/layout.tsx
import type { Metadata } from 'next';

export const metadata: Metadata = {
  metadataBase: new URL('https://shopease.in'),
  title: { default: 'ShopEase — Online Shopping', template: '%s | ShopEase' },
  description: 'Buy mobiles, books and fashion at the best prices with fast delivery across India.',
  keywords: ['online shopping', 'mobiles', 'books'],
  openGraph: { type: 'website', siteName: 'ShopEase', locale: 'en_IN' },
  twitter: { card: 'summary_large_image' },
};

// app/cart/page.tsx
export const metadata: Metadata = { title: 'Your Cart', robots: { index: false } };

Rendered HTML

Example

curl -s localhost:3000/cart | grep -o "<title>.*</title>\|<meta name=\"robots\"[^>]*>"

Example output

<title>Your Cart | ShopEase</title>
<meta name="robots" content="noindex"/>

Note: metadata and generateMetadata work only in Server Components (layouts and pages).