要約
メモ
Migrate Nextjs 13.2 by otoyo · Pull Request #174 · otoyo/easy-notion-blog
The Metadata API is used to define application metadata that improves SEO and web sharability.
There are two ways to define Metadata:
metadata
object or a dynamic generateMetadata
function in a layout.js
or page.js
file.// either Static metadata
export const metadata = {
title: '...',
};
// or Dynamic metadata
export async function generateMetadata({ params }) {
return {
title: '...',
};
}
Good to know
- The
metadata
object andgenerateMetadata
function exports are only supported in Server Components.- You cannot export both the
metadata
object andgenerateMetadata
function from the same route segment.
metadata
objectTo define static metadata, export a Metadata
object from a layout.js
or static page.js
file.
layout.tsx|page.tsx
import { Metadata } from 'next';
export const metadata: Metadata = {
title: '...',
description: '...',
};
export default function Page() {}
See the Metadata object reference for a complete list of supported fields.