garmeeh / next-seo

Next SEO is a plug in that makes managing your SEO easier in Next.js projects.
MIT License
7.52k stars 388 forks source link

SEO Info not updated with the API #1453

Open fackerlee opened 4 months ago

fackerlee commented 4 months ago

Issue: I've been working on enhancing the SEO capabilities of our product details pages. The goal is to dynamically populate meta tags with relevant information fetched from an API based on the product details being viewed.

Current Behavior: To achieve this, I've implemented a solution where I retrieve the product ID from the URL, call our API to fetch the necessary data, and then attempt to update the meta tags with this retrieved information. However, I've encountered an issue where the initial load of the page results in null values being populated in the meta tags. Although subsequent API calls successfully fetch the data, the meta tags remain unchanged and continue to display null values.

Desired Outcome: Ideally, I would like the meta tags to be updated dynamically with the data retrieved from the API. This would ensure that the meta tags accurately reflect the content of the product details page, consequently improving the SEO performance of our GitHub repositories.

Proposed Solution: I believe that implementing a mechanism to update the meta tags upon successful retrieval of data from the API would address this issue effectively. This could involve triggering a function to update the meta tags within the callback of the API request, ensuring that they reflect the latest data fetched.

Request for Assistance: I'm reaching out to seek guidance on how best to achieve this dynamic updating of meta tags within GitHub repositories. Any insights, recommendations, or examples of similar implementations would be greatly appreciated.

Thank you for your attention to this matter.

garmeeh commented 3 months ago

Hey @fackerlee, it sounds you may be fetching the extra data to update the meta tags on the client side?

For SEO you should be requesting this server side for the first render of the page.

A useful way of testing what search engines see is to disable javascript and load the page. Or "View Page Source"