使用 Javascript 解决 SEO 问题

发布于 2024-09-16 10:41:56 字数 462 浏览 20 评论 0原文

我想知道在哪个阶段可以开始使用 Javascript 操作 HTML 元素/内容,以免损害 SEO?

我在某处读到,使用 CSS 属性 display:none 隐藏的 HTML 内容经常受到 Google 抓取工具的惩罚,我相信这是有充分理由的......我问这个是因为我打算有一些最初隐藏的 div 面板,但一旦用户单击适当的链接就会显示。因此,我的目的并不是完全向用户隐藏内容 - 只是最初是为了给他们更好的用户体验 - 恐怕谷歌可能不会这样看!

我这样做的原因是为了防止在我的 Javascript 定位、隐藏和整理所有内容之前,出现可怕的无样式 html 元素(定位)的瞬间(或者在某些情况下,整整 2 秒)。因此,在最前面添加 display:none ,然后使用 Javascript 来切换可见性本来是理想的选择,但这显然是 Google 搜索引擎机器人的禁忌。

各位专家有什么建议吗?谢谢你!

I would like to know at which stage is it okay to start manipulating HTML elements/content using Javascript so as not to impair SEO?

I have read somewhere that HTML content that is hidden using the CSS property display:none is often penalized by Google crawlers, with good reason from what I'm led to believe...I ask this as I intend to have some div panels that are initially hidden, but shown once the user clicks on an appropriate link. My intention is therefore not to hide content from users entirely - just intially to give them a better user experience - I'm afraid Google may not see it that way!

My reason for doing this is to prevent the split second (or in some cases, a full 2 seconds) of ghastly unstyled html elements (positioning), before my Javascript comes in to position, hide and neaten everything up. So adding the display:none at the forefront, and then using Javascript to toggle visibility would have been ideal, but is apparently a no-no with Google Search Engine bot.

Do you experts have any advice? Thank you!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

小兔几 2024-09-23 10:41:56

谷歌现在可以使用简单的 URL 替换技巧来抓取 AJAX 网站;您也许可以利用这一点,让 googlebot 查看页面的纯 html 版本以进行索引,而不是加载优化的页面;请参阅 http://code.google.com/web/ajaxcrawling/docs/入门.html

google can now crawl AJAX sites using a simple URL substitution trick; you might be able to take advantage of this to let googlebot see a plain html version of the page for indexing instead of your load-optimized page; see http://code.google.com/web/ajaxcrawling/docs/getting-started.html

dawn曙光 2024-09-23 10:41:56

如果相关内容存在于页面的 html 中,并且在页面最初加载完成时用户可以访问,那么就可以了。您希望确保 Google 可以引导用户访问您的页面并查看相关内容,而无需进一步交互。在初始加载后向 html 添加新内容(即来自服务器的内容)可能会给 SEO 带来问题。但是,如果在页面加载结束时所有内容都在 html 中,那么您不应该被停靠。请记住,良好的 SEO 策略要求使用标准的可用性方法,以便网络爬虫可以访问您的内容。

此外,每个页面都应遵循一个内容主题。示例:不要通过在一页上隐藏五个不同的不相关内容块“医疗设备、卡祖笛、最佳食客、摩托车、有毒废物”来滥用用户。理论上,您可以使用 javascript 和“display:none”将网站的所有内容放在一个页面上,等待“onClick”,但这闻起来像垃圾邮件。

编辑,与原始问题相关的附加信息:
动态显示内容的搜索引擎友好方式是加载它,然后对用户隐藏它。

If the content in question exists on the page in the html, and is accessible to the user by the time the page finishes loading initially, then you are okay. You want to make sure google can lead a user to your page and see the content in question without requiring further interaction. Adding new content to the html after the initial load (i.e. content from the server), can be problematic for SEO. However if all content is in the html by the end of the page load, then you shouldn't get docked. Keep in mind, good SEO strategy dictates using standard methods of usability so the web crawler can access your content.

Also, each page should follow a content theme. Example: Don't abuse users by hiding five different unrelated blocks of content "medical devices, kazoos, best diners, motorcycles, toxic waste" on one page. Theoretically you could take all of your site's content and lay it out on one page using javascript and 'display:none' waiting for an 'onClick', but that smells like spam.

EDIT, additional info as pertaining to the original question:
The search engine friendly way to display content dynamically is to load it, then hide it from the user.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文