How to use open primitive tag in next js 13?
P粉768045522
P粉768045522 2023-11-10 23:03:51
0
1
947

In the recent Next JS 13 update, they introduced a new way of handling meta tags that differs from the traditional way of creating a Next Head and writing the usual html meta tags. In the new method, we create a metadata object-like method. But I haven't found a way to use open graph metadata.

export const metadata = { title: " this is the title of the web", description: " this is the description section", ogtitle: "this is open graph title for testing", // i thought this could be the case };

So how do I use open graph in metadata?

P粉768045522
P粉768045522

reply all (1)
P粉709644700

MetadataA portion of the object dedicated to OpenGraph’s metadata.

Please refer toRelated documentationfor more information details.

The short version is this:

export const metadata = { openGraph: { title: 'this is open graph title for testing', description: 'Some description', } };

I also expect that you need to dynamically generate this data based on path, search parameters and query. If so, useexport async function generateMetadata(...)instead ofexport const metadata.Related documentationis of great help. p>

    Latest Downloads
    More>
    Web Effects
    Website Source Code
    Website Materials
    Front End Template
    About us Disclaimer Sitemap
    php.cn:Public welfare online PHP training,Help PHP learners grow quickly!