大网数据广告活动
网站运营与故障问答

Are <button role=“link”>s indexable by Google?

· 52CE 我爱测

For complicated reasons, we can't use <a href=""> tags on part of one of our pages. If we use <button role="link"> , will Search Engines crawl the page? If not, is there another way to tell google to crawl <button> s?

问题原文

原帖链接 · Eliezer Berlin · CC BY-SA 4.0

For complicated reasons, we can't use <a href=""> tags on part of one of our pages.

If we use <button role="link">, will Search Engines crawl the page? If not, is there another way to tell google to crawl <button>s?

已采纳解答

原帖链接 · Stephen Ostermiller · CC BY-SA 4.0

Googlebot does scan JavaScript files for things that look like links. For example if you use the Javascript var s="/foo/bar.html" Google will likely try to crawl /foo/bar.html to see if it can find a page there. In my experience Googlebot will try to crawl any reasonable length string literal than contains a slash but no spaces. Googlebot is likely to miss URLs that don't look enough like URLs or ones which are built from other smaller strings.

I've never tried to rely on this Googlebot heuristic to get my sites crawled and indexed. I wouldn't recommend that you do either. It isn't clear that Googlebot passes any link juice to URLs discovered in JavaScript files. So even if Googlebot finds your pages this way, it isn't likely to index them, and certainly not likely to rank them well.

Single page sites are very hard for Googlebot to grok. Even though Googlebot can execute JavaScript, Googlebot doesn't simulate scrolling or clicking on anything. To get an AJAX powered site crawled, you really need to use normal <a href= links in your pages for Googlebot. You can intercept clicks on links with Javascript and return false or event.preventDefault to change the content without having the browser load a whole new page.

If you really can't use <a> tags, I'd recommend putting the URLs into data attributes on the buttons. Google should be able to crawl those as well. See Does Googlebot crawl items that look like URLs in HTML5 data-* attributes? I don't know if those would pass link juice either, but I'd find it more plausible that they would do so.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Webmasters Stack Exchange
适用范围
以原帖系统、软件版本与发布日期为准(2020-02-20)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。