Google crawlers can only follow links with the proper a tag, not JavaScript.
Use a tags to provide a link to another page
I think it is well known that <a> tag
is used as an element to take you to another page, but sometimes I see cases of page links using <button> tag
, or using <a> tag or JavaScript
.
You may be using this for a specific purpose, but if you want Google's crawlers to crawl through your site, you should use <a> tags
.
Because Google's crawlers cannot follow links if they are not proper tags.
The official documentation states the following.
Google can follow your links only if they use proper tags with resolvable URLs:
(omitted)
Google can follow links only if they are an tag with an href attribute. Links that use other formats won't be followed by Google's crawlers. Google cannot follow links without an href tag or other tags that perform a links because of script events. Citation : Create Crawlable Links | Google Search Central | Documentation | Google Developers
As shown in the above page, the crawler cannot follow the following code.
<a routerLink="some/path">
<span href="https://example.com">
<a onclick="goto('https://example.com')">
Another example of a ** un-resolvable URLs** is a JavaScript or anchor link, such as
- javascript:goTo('products')
- javascript:window.location.href='/products'
- #
See Also
Please also check the following forum and video for reference.
- BUTTONタグでリンクを作成した場合、rel=" nofollow"をつけたらどうなりますか?- Google 検索セントラル コミュニティ
- (50) Links & JavaScript | WMConf Lightning Talks - YouTube