Next.js Discord

Discord Forum

Meta tags are not being returned upon initial page load

Answered
Hierran Wolfdog posted this in #help-forum
Open in Discord
Hierran WolfdogOP
I discovered a strange issue when working on a project of mine. I expected Discord embeds to work, however when trying them they do not appear to work. After further debugging, on the Discord embed debugger, the embed just gets returned as blank. Even more puzzling, when I go to curl my website, the meta tags are simply not present, and as far as I'm aware, for embeds, meta tags need to be present immediately.

My question is, how can I fix this? I am using next/head and the <Head> component is right at the top of the page, so I'm really not sure what's going on. Any help would be greatly appreciated, thanks!
Answered by Hierran Wolfdog
I fixed the issue, I moved the <Head> component to _app.js and each page now returns getInitialProps or getServerSideProps depending on if data fetch is required for title and description etc
View full answer

3 Replies

Madeiran sardinella
I suppose you are getting the data for the metadata in server side, right?
are you using app router? @Hierran Wolfdog
Hierran WolfdogOP
I fixed the issue, I moved the <Head> component to _app.js and each page now returns getInitialProps or getServerSideProps depending on if data fetch is required for title and description etc
Answer