简体   繁体   English

Ajax页面部分加载和Google

[英]Ajax page part load and Google

I have some div on page loaded from server by ajax, but in the scenario google and other search engine don't index the content of this div. 我在ajax从服务器加载的页面上有一些div,但是在这种情况下,google和其他搜索引擎不会为该div的内容编制索引。 The only solution I see, it's recognize when page get by search robot and return complete page without ajax. 我看到的唯一解决方案是,它可以识别搜索机器人获取页面并返回不带ajax的完整页面的时间。 1) Is there more simple way? 1)还有更简单的方法吗? 2) How distinguish humans and robots? 2)如何区分人和机器人?

You could also provide a link to the non-ajax version in your sitemap, and when you serve that file (to the robot), you make sure to have included a canonical link-element to the "real" page you want users to see: 您还可以在站点地图中提供指向非ajax版本的链接,并且在将文件提供给机器人时(确保提供给机器人),请确保已包含指向用户希望看到的“真实”页面的规范链接元素:

<html>
    <head>
        [...]
        <link rel="canonical" href="YOUR_CANONICAL_URL_HERE" />
        [...]
    </head>
    <body>
        [...]
        YOUR NON_AJAX_CONTENT_HERE
    </body>
</html>

edit: if this solution is not appropriate (some comments below points out that that this solution is non-standard and only supported by the "big-three"), you might have to re-think whether you should make the non-ajax version the standard solution, and use JavaScript to hide/show the information instead of fetching it via AJAX. 编辑:如果此解决方案不合适(以下一些评论指出此解决方案是非标准的,并且仅受“ big-three”支持),则可能需要重新考虑是否应制作非ajax版本标准解决方案,并使用JavaScript隐藏/显示信息,而不是通过AJAX获取信息。 If it is business critical information that is fetched, you have to realize that not all users have JavaScript enabled, and thus they won't be able to see this information. 如果获取的是关键业务信息,则必须意识到并非所有用户都启用了JavaScript,因此他们将无法看到此信息。 A progressive enhancement approach might be more appropriate in this case. 在这种情况下,渐进增强方法可能更合适。

Google gets antsy if you are trying to show different things to you users than to crawlers. 如果您尝试向用户展示与抓取工具不同的内容,那么Google就会感到恼火。 I suggest simply caching your query or whatever it is that needs AJAX and then using AJAX to replace only what you need to change. 我建议您简单地缓存查询或任何需要AJAX的查询,然后使用AJAX仅替换您需要更改的内容。 You still haven't really explained what's in this div that only AJAX can provide. 您仍然没有真正解释只有AJAX可以提供的该div中的内容。 If you can do it without AJAX then you should be, not just for SEO but for braille readers, mobile devices and people without javascript. 如果没有AJAX就可以做到这一点,那么您不仅应该针对SEO,还应该针对盲文阅读器,移动设备以及没有javascript的人们。

You can specify a sitemap in your robots.txt . 您可以在robots.txt指定站点地图。 That sitemap should be a list of your static pages. 该站点地图应该是您的静态页面的列表。 You should not be giving to Google a different page at the same URL, so you should have a different URL with static and dynamic content. 应该在同一个URL来给予谷歌不同的页面,所以你应该有静态和动态内容不同的URL。 Typically, the static URL is .../blog/03/09/i-bought-a-puppy and dynamic URL is something like .../search/puppy . 通常,静态URL是.../blog/03/09/i-bought-a-puppy而动态URL则是.../search/puppy

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM