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

Is it OK for SEO to make content available via AJAX when users click, but also to load that content on its own URL?

· 52CE 我爱测

I'm working on a website and I want to use AJAX for some content, but I'm worried about search engines crawling my site, and I know Google and other search engines only see contents that are currently in the DOM. What if I use AJ…

问题原文

原帖链接 · HOSSEIN · CC BY-SA 4.0

I'm working on a website and I want to use AJAX for some content, but I'm worried about search engines crawling my site, and I know Google and other search engines only see contents that are currently in the DOM.

What if I use AJAX but the contents also will be available in DOM after requests?

For example, I have a link called "Article 234" with the URL: https://example.com/?p=234. When the client clicks on the button it will load the contents from that article with AJAX but also if the user opens that URL sees the content, is it OK?

Something like this:

$("#article-234").click(e => {
    // Not redirecting
    e.preventDefault();

    // Instead, get content with ajax
    loadAjax(234);
});

已采纳解答

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

You are implementing this the correct way. Googlebot indexes what in on the page when it loads, before any user interaction. In fact, Googlebot never simulates any user interaction at all. Googlebot never clicks, scrolls, moves the mouse, or types. Anything that isn't in the DOM when the page loads is effectively invisible to Googlebot.

Googlebot will scan the DOM and looks for links to crawl, so the way that it navigates to other pages is similar to the navigation of a user without JavaScript. Your onclick event gets ignored by Googlebot, even though Googlebot can execute JavaScript to build the page.

So as long as your DOM has <a href=/?p=234 id=article-234>Article 234</a> in it, Googlebot will be able to crawl and index that link. It won't get confused that users could load that content with AJAX, because Googlebot will never do that itself.

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

资料来源与适用范围

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

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

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