搜索引擎可以索引JavaScript生成的网页吗? [英] Can search engines index JavaScript generated web pages?

查看:155
本文介绍了搜索引擎可以索引JavaScript生成的网页吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可以搜索引擎,比如Google索引JavaScript生成的网页吗?当您右键单击并在由JavaScript生成的页面中选择查看源代码(例如,使用GWT)时,您看不到动态生成的HTML。我想如果一个搜索引擎也看不到生成的HTML,那么没有太多索引,对吗?

你的怀疑是正确的 - JS生成的内容不能依赖于可见的搜索机器人。任何关闭JS的人都无法看到它 - 而且,上次我在一个我正在研究的网站上添加了一些测试(这是一个庞大的主流观众网站,每月有数十万个独立访问者) ,约有10%的用户没有以任何形式运行Javascript。这包括搜索机器人,禁用JS的PC浏览器,许多手机,使用屏幕阅读器的盲人等等等等。这是为什么通过JS生成的内容(没有后备选项)是一个真正的坏主意。



回到基础。首先,使用裸机(X)HTML ,在类似于REST的原则上创建您的站点(至少要求POST请求进行状态更改)。简单的语义标记,并忘记CSS和Javascript。

第一步是要正确地使用,并让整个站点(或尽可能多的有用)工作然后添加一个可视图层:CSS / graphics / media进行视觉打磨,但不会显着更改原始(X)HTML标记;允许原文纯文字网站保持完整并正常运作。保持您的标记干净!

第三是添加一个行为图层:Javascript(Ajax)。为具有Ajax功能的JS的用户/浏览器提供更快,更流畅,更好的体验......但只限于那些用户。没有Javascript的用户仍然欢迎;搜索机器人,视觉受损者,许多手机等等。



在网页设计圈中,这被称为渐进式增强。这样做,您的网站以一种合理的形式适用于每个人。


Can search engines such as Google index JavaScript generated web pages? When you right click and select view source in a page that is generated by JavaScript (e.g using GWT) you do not see the dynamically generated HTML. I suppose that if a search engine also cannot see the generated HTML then there is not much to index, right?

解决方案

Your suspicion is correct - JS-generated content cannot be relied on to be visible to search bots. It also can't be seen by anyone with JS turned off - and, last time I added some tests to a site I was working on (which was a large, mainstream-audience site, with hundreds of thousands of unique vistors per month), approx 10% of users were not running Javascript in any form. That includes search bots, PC browsers with JS disabled, many mobiles, blind people using screenreaders... etc etc.

This is why content generated via JS (with no fallback option) is a Really Bad Idea.

Back to basics. First, create your site using bare-bones (X)HTML, on REST-like principles (at least to the extent of requiring POST requests for state changes). Simple semantic markup, and forget about CSS and Javascript.

Step one is to get that right, and have your entire site (or as much of it as makes sense) working nicely this way for search bots and Lynx-like user agents.

Then add a visual layer: CSS/graphics/media for visual polish, but don't significantly change your original (X)HTML markup; allow the original text-only site to stay intact and functioning. Keep your markup clean!

Third is to add a behavioural layer: Javascript (Ajax). Offer things that make the experience faster, smoother, nicer for users/browsers with Ajax-capable JS... but only those users. Users without Javascript are still welcome; and so are search bots, the visually impaired, many mobiles, etc.

This is called progressive enhancement in web design circles. Do it this way and your site works, in some reasonable form, for everyone.

这篇关于搜索引擎可以索引JavaScript生成的网页吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆