Metadata in NextJS
Let's now look at how to add a title and meta description to the page. In NextJS, they are handled together and are therefore referred to by the common term metadata.
Metadata is specified using a special object containing the title and meta description:
{
title: '...',
description: '...',
};
In this case, NextJS will automatically insert the metadata
into the corresponding tags. We don't need to worry
about it. That's why the main site layout
lacks the head tag,
as it will be generated automatically:
export default function RootLayout({children}) {
return (
<html lang="en">
<body>
{children}
</body>
</html>
);
}
There are various ways to specify metadata. We will study them in the following lessons.