Metadata on web pages plays a crucial role. It describes the page's content and includes keywords related to it. Search engines often display this metadata in their results, making its accuracy and detail essential for attracting users to a site. Typically, this information is presented through meta tags.
import type { Metadata } from 'next';
// Static metadata
export const metadata: Metadata = {
title: '...',
};
import type { Metadata } from 'next';
// Dynamic metadata
export async function generateMetadata({ params }): Promise<Metadata> {
return {
title: '...',
};
}
The metadata object and the generateMetadata function can only be used in Server Components. It is not allowed to export both the metadata object and the generateMetadata function within the same route segment.
Dynamic metadata, which relies on dynamic data such as current route parameters or external API data, can be configured by exporting a generateMetadata function that returns a Metadata object.
Ready to transform your business with our technology solutions? Contact Us today to Leverage Our ReactJS Expertise.
0