SEO impact of onclick handlers in place of links

by carl   Last Updated June 12, 2019 10:04 AM

I have a question similar to the one posted here.

I'm building a React application which has very strict SEO requirements, so I'm wondering if the following approach is an issue:

For all of our navigation/routing, we're using onClick handlers that push the user to the new location within the app. The way I've built the components means that the generated HTML does not have anchor tags, and thus there are no links/hrefs anywhere in the application.

Can googlebot handle this? Even if it can, I have a feeling it may adversely affect crawlers' ability to properly index the linking structure within the app.

If this is an issue, I will need to add links to everything, and simply prevent the default behavior before triggering the route. This way the crawler would at least be able to see links with href attributes in the HTML that point to the proper URLs.

Unfortunately, since this is a new application, it's not publicly available yet for me to test using the Fetch as Google tool.



Answers 3


See here for an explanation to a similar question.

Also, here is a supporting article from Google.

carl
carl
March 14, 2018 01:03 AM

Googlebot should be able to handle onclick links. You can test it by seeing the crawl frequency of Googlebot in search console and seeing if it crawls the onclicks.

Javascript is unreliable and it's hard to say if Google will be able to see it 100% of the time, but tests have been performed and shown that Google does crawl onclick links.

We also tested standard JavaScript links. These are the most common types of JavaScript links that SEOs have traditionally recommended be changed to plain text. These tests included JavaScript links coded with:

Functions outside of the href Attribute-Value Pair (AVP) but within the a tag (“onClick”) Functions inside the href AVP (“javascript:window.location“) Functions outside of the a but called within the href AVP (“javascript:openlink()”) etc. Result: The links were fully crawled and followed.

Source: https://searchengineland.com/tested-googlebot-crawls-javascript-heres-learned-220157

Michael d
Michael d
March 14, 2018 01:13 AM

Google could probably handle onclick links but you should make a test before your app is finished. Nonetheless, I prefer the old fashion way to link in order to make easier the searchers job and avoid problems.

Have in mind that the Google's ajax crawling method was deprecated a few years ago and that could be because they are able to read the DOM, not just the source code (question 37).

As I said, I would use normal links but if you have to keep the onclick property, you should use:

  • Fetch as Google tool in order to make sure links are visible
  • HTML sitemap somewhere on the site
  • XML sitemap submitted to Google Search Console (and Bing)
Emirodgar
Emirodgar
March 14, 2018 07:47 AM

Related Questions


Updated September 03, 2018 11:04 AM

Updated July 01, 2017 23:04 PM

Updated May 24, 2018 08:04 AM