gpt4 book ai didi

url - 人类可读的 URL : preferably hierarchical too?

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

在关于人类可读 URL 的 now migrated question 中,我允许自己详细说明我的一个小爱好:

When I encounter URLs like http://www.example.com/product/123/subpage/456.html I always think that this is an attempt on creating meaningful hierarchical URLs which, however, is not entirely hierarchical. What I mean is, you should be able to slice off one level at a time. In the above, the URL has two violations on this principle:

  1. /product/123 is one piece of information represented as two levels. It would be more correctly represented as /product:123 (or whatever delimiter you like)
  2. /subpage is very likely not an entity in itself (i.e., you cannot go up one level from 456.html as http://www.example.com/product/123/subpage is "nothing").

Therefore, I find the following more correct:

http://www.example.com/product:123/456.html

Here, you can always navigate up one level at a time:

  • http://www.example.com/product:123/456.html — The subpage
  • http://www.example.com/product:123 — The product page
  • http://www.example.com/ — The root

Following the same philosophy, the following would make sense [and provide an additional link to the products listing]:

http://www.example.com/products/123/456.html

Where:

  • http://www.example.com/products/123/456.html — The subpage
  • http://www.example.com/products/123 — The product page
  • http://www.example.com/products — The list of products
  • http://www.example.com/ — The root

我采用这种方法的主要动机是,如果每个“路径元素”(由 / 分隔)都是独立的1,您将始终能够导航到“parent”,只需删除 URL 的最后一个元素。当我想转到父目录时,这就是我(有时)在我的文件资源管理器中所做的。按照相同的逻辑,用户(或搜索引擎/爬虫)可以做同样的事情。我认为非常聪明。

另一方面(这是问题的重要部分):虽然我永远无法阻止用户尝试访问他自己截断的 URL,我是不是错了断言(并尊重)搜索引擎可能会做同样的事情? 即,是否有理由期望没有搜索引擎(或实际上:谷歌)会尝试访问 http://www.example。 com/product/123/subpage(上面第 2 点)? (还是我真的只考虑了人为因素?)

这不是关于个人偏好的问题。这是关于我对爬虫/索引器的期望以及在设计 URL 时我应该在多大程度上考虑非人类 URL 操作的技术问题。

此外,http://www.example.com/product/123/subpage/456.html 的结构“深度”为 4,其中 http://www。 example.com/products/123/456.html 只有 3。有传言说这个深度会影响搜索引擎排名。至少,有人告诉我。 (现在很明显,搜索引擎优化不是我最了解的。)这(还是?)是真的吗:层级深度(目录数量)会影响搜索排名吗?

那么,我的“直觉”在技术上是否合理,还是我应该把时间花在其他事情上?


示例:(几乎)正确地做事
Good ol' SO 几乎是正确的。恰当的例子:配置文件,例如 http://stackoverflow.com/users/52162:

  • http://stackoverflow.com/users/52162 — 单一配置文件
  • http://stackoverflow.com/users — 用户列表
  • http://stackoverflow.com/ — 根目录

但是,配置文件的 canonical URL 实际上是 http://stackoverflow.com/users/52162/jensgram 这似乎是多余的(在两个层次结构级别上表示相同的端点)。备选方案:http://stackoverflow.com/users/52162-jensgram(或任何其他一贯使用的分隔符)。


1) 包含不依赖于“更深”元素的完整信息。

最佳答案

“http://www.example.com/product:123/456.html”这种分层 url 与“http://www.example.com/product/123/subpage”一样无用,因为当用户看到您的网址时,他们不关心您数据库中的标识符,他们想要有意义的路径。这就是 StackOverflow 将问题标题放入 url 的原因:“http://stackoverflow.com/questions/4017365/human-readable-urls-preferably-hierarchical-too”。

Google 建议不要替换像“http://www.example.com/?product=123&page=456”这样的常用查询,因为当每个站点都开发自己的方案时,抓取工具不知道每个部分的含义,重要与否。 Google 发明了复杂的机制来查找重要的参数并忽略不重要的参数,这意味着您将获得更多页面到索引中并且重复的页面会更少。但是,当 Web 开发人员发明自己的方案时,这些算法往往会失败。

如果您同时关心用户和爬虫,您应该改用这样的网址:

此外,搜索引擎对 url 中包含关键字的页面给予更高的评级。

关于url - 人类可读的 URL : preferably hierarchical too?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4017365/

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