How to add metadata
Last updated
Was this helpful?
Last updated
Was this helpful?
Here is a guide on how to add metadata. This entire documentation is referenced from Nextjs, so for a better view, please check this Nextjs tutorial -
The Metadata APIs can be used to define your application metadata for improved SEO and web shareability and include:
Special that can be used to add static or dynamically generated and .
With all the options above, Next.js will automatically generate the relevant <head>
tags for your page, which can be inspected in the browser's developer tools.
There are two default meta
tags that are always added even if a route doesn't define metadata:
The sets the character encoding for the website.
The sets the viewport width and scale for the website to adjust for different devices.
The other metadata fields can be defined with the Metadata
object (for ) or the generateMetadata
function (for ).
To define static metadata, export a from a static or file. For example, to add a title and description to the blog route:
app/blog/layout.tsx
app/blog/[slug]/page.tsx
Behind-the-scenes, Next.js will stream metadata separately from the UI and inject the metadata into the HTML as soon as it's resolved.
You can view a full list of available options, in the .
You can use function to fetch
metadata that depends on data. For example, to fetch the title and description for a specific blog post: