Does Google read dynamic canonical tags?
-
Does Google recognize rel=canonical tag if loaded dynamically via javascript? Here's what we're using to load:
<script> //Inject canonical link into page head if (window.location.href.indexOf("/subdirname1") != -1) { canonicalLink = window.location.href.replace("/kapiolani", ""); } if (window.location.href.indexOf("/subdirname2") != -1) { canonicalLink = window.location.href.replace("/straub", ""); } if (window.location.href.indexOf("/subdirname3") != -1) { canonicalLink = window.location.href.replace("/pali-momi", ""); } if (window.location.href.indexOf("/subdirname4") != -1) { canonicalLink = window.location.href.replace("/wilcox", ""); } if (canonicalLink != window.location.href) { var link = document.createElement('link'); link.rel = 'canonical'; link.href = canonicalLink; document.head.appendChild(link); } script>
-
I believe it's a limitation of our CMS. I'll see if we can try it in htaccess or PHP. Thanks for the insight.
-
Thanks for the reply. Doesn't appear Google is recognizing the tag because duplicate pages with it are still showing up in SERPs.
-
I Wouldn't bet on that working. Why not use the exact same code in .htaccess format, or even PHP? Javascript is a coding language that is parsed after the window starts loading, it's not like PHP where it gets parsed before the load.
Thanks
-
Hi SoulSurfer,
Read This http://searchengineland.com/tested-googlebot-crawls-javascript-heres-learned-220157
The google bot was able to read rel=nofollow and links were not followed. So I would think the same for rel=canonical as well.
Thanks,
Don
Got a burning SEO question?
Subscribe to Moz Pro to gain full access to Q&A, answer questions, and ask your own.
Browse Questions
Explore more categories
-
Moz Tools
Chat with the community about the Moz tools.
-
SEO Tactics
Discuss the SEO process with fellow marketers
-
Community
Discuss industry events, jobs, and news!
-
Digital Marketing
Chat about tactics outside of SEO
-
Research & Trends
Dive into research and trends in the search industry.
-
Support
Connect on product support and feature requests.
Related Questions
-
Which Version Url to Use for Canonical Tags and in General for Homepage.
I want to put canonical tags on the homepage of a site. cant figure out the version of URL of the homepage should be with a / at the end or without the / ( www.example.com of www.example.com/ ) if I put into the google the URL with / I get the URL without the / in my browser, and it isn't showing as a redirect in my moz extension or other tools. But when I copy the URL from browser and paste elsewhere it pastes with a / I have two questions 1 - in general how does it work with URLs of homepages - I see this happening with lots of sites? 2 - which URL should I set as the canonical version of my homepage? Thanks so much
Technical SEO | | Ruchy0 -
Google Bot Noindex
If a site has the tag, can it still be flagged for duplicate content?
Technical SEO | | MayflyInternet0 -
Canonicals
We have a client that has his products listed on 20+ different websites, including 4 of his own. Also, he only has 1 of everything, so once he sells it then the product is gone. To battle this duplication issue, plus having a short internet lifespan of less than 4 weeks, I was wondering if it would be a good idea to canonical the products back to the category page. Kind of like using canonical tags on your "used blue widget" and "used red widget" pages back to the "used widgets" page. Would this help with the duplicate content issues? Is this a proper use of a canonical?
Technical SEO | | WhoWuddaThunk0 -
Changing the Title Tag But It Does Not Reflect In Google Results
I have changed the page title for www.finanscaddesi.com to read as "Finans Caddesi | Paranın Pusulası" (as you can see from the source code) But Google still shows the old version. I have checked Google's guidelines regarding page titles. They say if we find a reference anchor text that is linking to the page (such as a DMOZ entry) we may use the anchor text as page title. I wonder whether there is a method I can follow to change the title tag to appear as "Finans Caddesi | Paranın Pusulası" in Google search results. Thanks in advance!
Technical SEO | | merkal20130 -
Canonical question
I have at least three duplicate main pages on my website: www.augustbullocklaw.com www.augustbullocklaw.com/index augustbullocklaw.com I want the first one, www.augustbullocklaw.com to be the main page. I put this code on the index page and uploaded it to my site: http://www.augustbullocklaw.com/canonical-version-of-page/" rel="canonical" /> This code now appears on all three pages shown above. Did I do this correctly? I surmise that www.augustbullocklaw.com is pointing to itself. Is that ok? I don't know how to take the cononical code off the page that is the page I want to be the main page. (I don't know how to remove it from www.augustbullocklaw.com, but leave it on www.augustbullocklaw.com/index and augustbullocklaw.com) Thanks
Technical SEO | | Augster990 -
Duplicate title tags and meta description tags
According to GWT, it seems that some of the pages on my website have duplicate title and meta tags. The pages identified by Google are nothing but dynamic pages: http://www.mywebsite.com/page.php
Technical SEO | | sbrault74
http://www.mywebsite.com/page.php?param=1
http://www.mywebsite.com/page.php?param=2 The thing is that I do use the canonical link tag on all pages. Should I also use the "robots noindex" tag when the page is invoked using a GET parameter? Again sorry for my english. Thank you, Stephane1 -
Can somebody explain Canonical tags and the technical elements of SEO?
Newbie here,and learning fast. But... I can't help but feel the technical elements of SEO (i.e. canonical tags, javascript amongst others) are holding me back. My knowledge of programming and coding is basic at best. Do I have to have an understanding of this to get ahead in SEO or is it simply a case of reading some more and knowing the techniques? What percentage of SEO is technical (e.g. html coding etc...) Thanks in advance. N. p.s. could someone explain what canonical tags are?
Technical SEO | | Buzzwords0 -
Did I implement the Canonical Correctly?
Hello, I am trying for the first time to implement a canonical redirect on a page and would really appreciate it if someone could tell me if this was done correctly. I am trying to do a canonical redirect: -from http://www.diamondtours.com/default.aspx -to http://www.diamondtours.com/ As you will see in the source code of the default.aspx page, the line of code written is: <link rel="canonical" href="http://www.diamondtours.com" /> Is this correct? Any guidance is greatly appreciated. Jeffrey Ferraro
Technical SEO | | JeffFerraro0