0
votes

I've migrated from create-react-app to create-next-app to my website, but the Head(app/head) component isn't working properly

Assuming I have a blog, and in pages, I have the following structure: pages/blog/index.js, pages/blog/[slug].js. In [slug].js, I'm using the Head component so it takes the title of the blog post: <Head><title>{post.title}</title></Head> The problem is that when using react-share on the blog post it doesn't put the right title, even when I do an inspect element on the page, I can see the right Head values, but the Facebook debug (https://developers.facebook.com/tools/debug/) tool doesn't recognize the right title.

Any help will be used. thanks, guys

1
Maybe the title is not being rendered on the server, and the FB debug tool doesn't run javascript, so it never sees the title? - Cully
yes, that was the problem. i fixed it - hosu andrei
You should post an answer to your own question; it could benefit others in the future. - Cully

1 Answers

0
votes

the answer is that you should bring data via getInitialProps so it can accessible to component and not via useEffect :)