Next.js Discord

Discord Forum

Metadata generate not work

Unanswered
Giant Angora posted this in #help-forum
Open in Discord
Giant AngoraOP
Hello , i have a simple page and want to generate metadata for it , but it not work

7 Replies

Giant AngoraOP
import React from "react"

export const metadata = {
    title: `My Website`,
    description: "This Is My Website",

    openGraph: {
        title: `My Website`,
        description: "This Is My Website",
    },

        twitter: {
        title: `My Website`,
        description: "This Is My Website",
    }
};

export default function MainLayout({ children }) {
    return (
        <html>
            <body>
                {children}
            </body>
        </html>
    )
}
layout.jsx
When i load page , it still on localhost:3000
And something intersting
When i edit code , and switch on page , it will update and generate metadata , and when i refresh page , it wont generate anymore
American black bear
Your implementation is correct unless you have a page that also exports metadata which will override the layout metadata.
Probably you are dealing with browser caching the metatags or something
try going to the network tab in your browser dev tools and checking the [ ] disable cache checkbox