Google paperwork methods to inject canonical tags utilizing JavaScript

News Author


Google has up to date its JavaScript search engine optimization assist doc so as to add technical particulars on methods to inject canonical hyperlink tags utilizing JavaScript. Google added a brand new part titled “correctly inject rel=”canonical” hyperlink tag.”

What’s new. Right here is the brand new part the place Google recommends to not implement your canonical tags utilizing JavaScript, however when you should, Google explains that is the right method to take action. Google wrote:

Whereas we don’t advocate utilizing JavaScript for this, it’s attainable to inject a rel=”canonical” hyperlink tag with JavaScript. Google Search will choose up the injected canonical URL when rendering the web page. Right here is an instance to inject a rel=”canonical” hyperlink tag with JavaScript:

Google added this warning stating “When utilizing JavaScript to inject the rel=”canonical” hyperlink tag, ensure that that is the one rel=”canonical” hyperlink tag on the web page. Incorrect implementations would possibly create a number of rel=”canonical” hyperlink tag or change an current rel=”canonical” hyperlink tag. Conflicting or a number of rel=”canonical” hyperlink tags might result in sudden outcomes.”

Hit and miss. We’ve got seen instances the place Google can choose up these canonical tags or different embedded components, even structured knowledge, utilizing JavaScript. However it may be hit and miss, so it is strongly recommended that if you’re going to use JavaScript particularly to inject your canonical tags, comply with these instructions exactly.

Why we care. Once more, if you’re injecting canonical tags utilizing JavaScript, Google has lastly formally documented the right technique to implement it. So examine the documentation over right here and ensure your implementation follows Google’s suggestions.


New on Search Engine Land

About The Creator

Barry Schwartz a Contributing Editor to Search Engine Land and a member of the programming staff for SMX occasions. He owns RustyBrick, a NY primarily based net consulting agency. He additionally runs Search Engine Roundtable, a preferred search weblog on very superior SEM matters. Barry may be adopted on Twitter right here.