gpt4 book ai didi

seo - hashHistory、_escaped_fragment_ 和 Google

转载 作者:塔克拉玛干 更新时间:2023-11-03 02:34:30 28 4
gpt4 key购买 nike

我使用 React Router 已经有一段时间了,我一直在使用 hashHistory 来处理路由。在某些时候,我打算将应用程序转换到 browserHistory,但我很好奇为什么 Google 的“Fetch as Google”功能似乎对根路由以外的任何东西都不起作用(/)。很明显,它正在渲染某些东西,而不是服务器未处理的路由。 (下图)

enter image description here

我看到 Google 有 deprecated their AJAX crawling scheme ,这让我相信我不再需要处理 ?_escaped_fragment_=,但即便如此,我也无法让 Google 呈现任何其他路线。

例如,网站是 www.learnphoenix.io,类(class)列在 www.learnphoenix.io/#/phoenix-chat/lessons 下。然而,谷歌的 Fetch as Google网站管理员中的功能重定向到主页并仅呈现主页。使用 _escaped_fragment_ 会导致相同的结果。

有没有办法允许 Google 使用 hashHistory 索引我的网站,或者我是否只需要接受只有我的主页会被索引,直到我切换到 browserHistory

最佳答案

默认情况下,google 似乎会忽略 url 片段 (#)。根据这篇可能过时的文章,使用 #!将告诉谷歌这些片段可用于定义不同的规范页面。

https://www.oho.com/blog/explained-60-seconds-hash-symbols-urls-and-seo

值得一试,尽管 ReactRouter 不支持 Hashbang,因为它应该被弃用。

更好的选择可能是硬着头皮在你的 react-router 中使用 browserHistory (pushState)。问题在于,如果您运行的是静态无服务器应用程序,/phoenix-chat/lessons 之类的路径将返回 404。在 AWS 中,也有一个破解方法。将您的 404 页面设置为您的应用索引页。

http://blog.boushley.net/2015/10/29/html5-deep-link-on-amazon-s3/

感觉很脏,但还是值得一试。希望这个答案对您有所帮助!

关于seo - hashHistory、_escaped_fragment_ 和 Google,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39461343/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com