Set page metadata
A Pages Router page needs a route-specific title or description.
Next.js 16+ · Component
next/head adds page-specific elements to the HTML head in the Pages Router. It is deprecated for App Router usage, where the built-in Metadata API replaces it.
next/head is a Pages Router component that contributes elements such as titles and metadata to the HTML head. It is not the App Router approach: App Router projects should use Next.js built-in SEO support through the Metadata API.
import Head from 'next/head'Rendered head elements are added to the document head while the component is mounted.
Head from next/head and place page-specific head elements inside it.key to deduplicate repeated head tags; title and base receive automatic duplicate checking.import Head from 'next/head'
export default function Page() {
return (
<>
<Head>
<title>My page title</title>
<meta name="description" content="A page description" />
</Head>
<main>Content</main>
</>
)
}This Pages Router component adds page-specific elements to the document head. In the App Router, use the Metadata API instead.
A Pages Router page needs a route-specific title or description.
Several components contribute equivalent head tags on one page.
A legacy Pages Router application is being maintained during migration.
next/head component?Head is a Pages Router component imported from next/head. It lets a page contribute elements such as title and meta to the HTML head.
Follow-up: How does this differ in the App Router? Use the built-in Metadata API rather than next/head.
The component collects its rendered head elements and removes them when the component unmounts. Therefore, each page should fully describe the head entries it requires instead of relying on another page's entries.
Follow-up: What can happen if a page assumes a previous page populated the head? Its required metadata may be absent after navigation because prior contents are cleared.
Duplicate tags can be avoided with the key property. Next.js already checks title and base elements for duplicates, so those two tags do not need keys for this purpose.
Follow-up: When should a key be added? Add one when multiple matching head elements could otherwise be rendered and should be deduplicated.
Metadata APInext/scriptApp Router migrationPages Router