I'm using react js and react-helmet to change the canonical tag values in the pages. But, it is not updating the value. Everywhere it is showing https://www.example.com
, which is mentioned in my index.php
file. I need to update the canonical link. I have earlier used jquery, but it didn't work out. It was updating in element-inspector
and not in page-source
but google was marking as duplicate pages.
I'm following https://github.com/nfl/react-helmet#server-usage
canonical url code
var newCanonicalUrl = "https://www.examle.com" + this.state.productUrl;
inside render function
return(<Helmet link = {[{"rel" : "canonical", "href" : {newCanonicalUrl}}]}>);