s-yadav / react-meta-tags

Handle document meta/head tags in isomorphic react with ease.
MIT License
226 stars 47 forks source link

re: Define id on tags so if you navigate to other page, older meta tags will be removed and replaced by new ones. #28

Open jamezening opened 5 years ago

jamezening commented 5 years ago

Hi,

First thank you for providing this meta tag module. I am probably one of several people trying to implement SEO-friendly pre-rendered React to serve from static hosting.

By the

Note: Define id on tags so if you navigate to other page, older meta tags will be removed and replaced by new ones.

should I add identical id's to tags that should be replaced? For instance if I have the following in my index.html

<meta id="og-title-meta-tags" property="og:title" content="original title" />

Would I have the following in a index.js file?

<meta id="og-title-meta-tags" property="og:title" content="new title" />

Also an off topic question - are all tags that can be used in possible to be used? i.e.) etc.?

Thank you for your reply.

alpha-beta-soup commented 5 years ago

+1 for this, it's not clear how it can be implemented. e.g. in my testing I have multiple application routes, but on loading each one, the application will add a new script tag in the head without destroying the old one. I suspect I'll need to work with the componentWillUnmount() lifecycle method and destroy any meta-tag child components, but it would be nice if this was already bundled into react-meta-tags.

niemenjoki commented 4 years ago

It's been a while since this issue was created but if you still need an answer, it seems to be the case that you need identical IDs for each "page". This will remove the old tags that have same IDs.