Adding OpenGraph meta tags to a page in my NextJS app has presented some challenges. I inserted the meta tags within the <Head>
component that is accessible through next/head
.
After testing the OpenGraph data with tools like the Facebook Sharing Debugger and opengraph.xyz, it was discovered that none of the og properties were properly set.
Further investigation revealed that while all the og meta tags I had set were visible in the 'Elements' tab of the developer tools under the <head>
element, they were not present when viewing the page source or making a request through Postman.
This led to the hypothesis that elements within the <Head>
component are added by NextJS via javascript after the page is loaded. This could explain why Facebook's crawler is unable to see the tags, as it may not execute javascript during the crawling process.
Is there a solution to ensure that the meta tags function correctly when using NextJS?