Static Metadata Passing from Content in NextJS
Let's now learn how to set custom metadata for each URL. To do this, the object with metadata needs to be exported from the file with the site content.
Let's see how this is done. Suppose we have some component with site content:
export default function Test() {
return <h1>test component</h1>;
}
Let's set the metadata for the URL corresponding to our content file:
export const metadata = {
title: 'My Test page',
description: 'Description for test page.',
}
export default function Test() {
return <h1>test component</h1>;
}
Create three pages on your site:
/about, /price, /contacts.
Add some text on these pages.
Create custom metadata for each page.