×
Friday, April 26, 2024

Google Explains How To Inject Canonical Tags Using JavaScript In Updated Doc - Search Engine Roundtable

Last updated Thursday, June 30, 2022 07:11 ET , Source: NewsService

Google has updated its JavaScript SEO help document to add a new section on how to properly inject canonical link tags using JavaScript. The document says Google does not recommend using JavaScript for this, however "it is possible to inject a rel=canonical link tag with JavaScript."

The help document adds that "Google Search will pick up the injected canonical URL when rendering the page."

A note Google made is that "when using JavaScript to inject the rel="canonical" link tag, make sure that this is the only rel="canonical" link tag on the page. Incorrect implementations might create multiple rel="canonical" link tag or change an existing rel="canonical" link tag. Conflicting or multiple rel="canonical" link tags may lead to unexpected results."

Here is a code example of how to do this:

Previously, as Google is doing now, Google warned against doing it this way but did say it can work.



Read Full Story: https://www.seroundtable.com/google-inject-canonical-tags-using-javascript-33680.html

Your content is great. However, if any of the content contained herein violates any rights of yours, including those of copyright, please contact us immediately by e-mail at media[@]kissrpr.com.