问题原文
原帖链接 · Lars Flieger · CC BY-SA 4.0
I have the following UI:
There are tabs which are <button>'s and when you select one there will be <a>-Links to different pages. It seems like Google will only index the Links on the first page (which is open by default) and not click the other buttons to the following links. The UI is built with react so only the links which are currently visible are in the HTML.
How can I achieve that Googlebot will also index the links of the other pages? Is it possible to tell the Googlebot to click a button? Any experiences?
已采纳解答
原帖链接 · Stephen Ostermiller · CC BY-SA 4.0
Googlebot does not simulate any user interaction with the page. It doesn't click, scroll, or type. There is no way to make it do so.
What Googlebot does instead is to scan the document object model (DOM) and look for links to follow. That leads to two potential solutions to your problem:
Put all the tabs in the DOM
If all the tabs' content are in the document, Googlebot will follow all the links, even if some of the tabs are currently hidden. Rather than implement the tabs such that the content gets loaded via AJAX when the user clicks, you can implement them so that all the content for all the tabs is loaded at page load. Then when the user clicks, the current tab can be hidden and the other tab shown.
Convert the buttons to links
Alternately, you can assign a different URL to each tab and convert each tab to link rather than using a button. Then Googlebot will discover each tab as its own page to crawl. When it crawls each tab, it will see the content and be able to crawl all the links.
摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。
