Welcome to WebmasterWorld Guest from 54.227.125.200

Forum Moderators: open

Message Too Old, No Replies

Canonical tag using javascript

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

     

nikhilrajr

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

Top Contributors Of The Month



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

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

WebmasterWorld Senior Member g1smd is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month



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

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

Top Contributors Of The Month



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

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

WebmasterWorld Senior Member lucy24 is a WebmasterWorld Top Contributor of All Time Top Contributors Of The Month



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

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

WebmasterWorld Senior Member g1smd is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month



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

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

nikhilrajr

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

Top Contributors Of The Month



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

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

WebmasterWorld Senior Member g1smd is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month



"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

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

Top Contributors Of The Month



Thanks g1smd. I got it..!

AirDisa

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

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

Top Contributors Of The Month



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

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

WebmasterWorld Senior Member whoisgregg is a WebmasterWorld Top Contributor of All Time 10+ Year Member



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

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

WebmasterWorld Senior Member lucy24 is a WebmasterWorld Top Contributor of All Time Top Contributors Of The Month



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

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
 

Featured Threads

Hot Threads This Week

Hot Threads This Month