homepage Welcome to WebmasterWorld Guest from 54.227.41.242
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
Forum Library, Charter, Moderator: open

JavaScript and AJAX Forum

    
Canonical tag using javascript
what are the drawbacks of using javascript for implementing canonical tag?
nikhilrajr




msg:4509229
 9:40 am on Oct 18, 2012 (gmt 0)

Hi,
I have implemented canonical tag using a javascript. This file also contains the google analytics code. Is there any drawbacks in using javascript for implementing canonical tag? Also if the canonical tag generated is having a # ie, www.example.com# will that be a problem?

 

g1smd




msg:4509230
 9:43 am on Oct 18, 2012 (gmt 0)

The canonical tag needs to be pure HTML.

www.example.com should always be immediately followed by a /

No idea if the # is a problem or not, but I would not include it.

nikhilrajr




msg:4509232
 9:52 am on Oct 18, 2012 (gmt 0)

Hi,
Thanks for the reply. I also want it to be in HTML code. I want proof to convince the client. Is there any official doc/reference which says it should be pure HTML?

lucy24




msg:4509235
 10:00 am on Oct 18, 2012 (gmt 0)

If it isn't html then you can't be 100% sure that all search engines everywhere will see it. Even google has only recently started executing javascript.

Seems to me the computer would wig out if it found the "canonical" tag attached to something that can't possibly be an URL, as in example.com#

g1smd




msg:4509236
 10:04 am on Oct 18, 2012 (gmt 0)

Bots don't do javascript so they won't see the canonical tag.

This is basic 'How the Web Works 101' stuff.

nikhilrajr




msg:4509238
 10:18 am on Oct 18, 2012 (gmt 0)

Thanks. But googlebot can execute javascript these days.
lucy24 - the canonical tag is like example.com/# So I don't think it will trouble the computer.

g1smd




msg:4509240
 10:20 am on Oct 18, 2012 (gmt 0)

"Execute javascript" and "have an indexing process that recognises a canonical tag generated by javascript" are two separate things.

I would not rely on it.

nikhilrajr




msg:4509242
 10:28 am on Oct 18, 2012 (gmt 0)

Thanks g1smd. I got it..!

AirDisa




msg:4509421
 2:56 pm on Oct 18, 2012 (gmt 0)

Google parses (executes) JavaScript. Google will 'see' the link if the code is correctly written. JavaScript links are on less stable ground and are required to pass muster with Google's JavaScript parser. Think of a way to test to make sure they record it into the index the way you want.

nikhilrajr




msg:4509445
 3:58 pm on Oct 18, 2012 (gmt 0)

AirDisa - I understand there are problems associated with javascript. Also it was adding a # at the end of URLs. Google hasn't said anything about using javascript for canonical tag. I was able to convince the web designer and client to use pure HTML like g1smd said..

whoisgregg




msg:4509447
 4:10 pm on Oct 18, 2012 (gmt 0)

Google may execute Javascript, but a javascript generated canonical tag is virtually guaranteed to be ignored by Google.

Remember, the purpose of the canonical tag is to specify the true location of content. Javascript injection is a significant enough security problem across the internet that Google is *incredibly* unlikely to trust a Javascript generated canonical tag.

Bottom line, it's got to be in the actual generated HTML of the page.

lucy24




msg:4509619
 1:30 am on Oct 19, 2012 (gmt 0)

A person-- which for these purposes includes a robot*-- can choose to disable javascript. You can't choose to disable HTML.


* Hmm. Maybe we should swipe an example from US law and say "a natural person" ;)

JetKor




msg:4513989
 12:39 am on Oct 31, 2012 (gmt 0)

Hi,

Even Google has only recently started executing JavaScript. I suggest that the canonical tag needs
to be pure HTML.

Best,
JetKor

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved