问题描述
首先是关于我的产品列表的一些详细信息:
Some details about my product list first:
- 静态,包含大约 400 个项目.
- 它不会再增长了.相信我.
- 没有重复的项目名称.
- 产品的属性不会改变.
基本上将我的产品列表视为元素周期表.我认为将 id 添加到带有slug 名称"(或任何名称)的 URL 没有任何意义.我宁愿有一个干净的 SEO 友好 URL.有什么我忽略的地方吗?
Basically think of my product list as the periodic table. I do not see any point of adding the id to the URL with the "slug name" (or whatever it's called). I'd rather have a clean SEO friendly URL. Is there something I'm overlooking here?
推荐答案
这里是关于 ID 和 slug 名称的事情:
Here's the thing about IDs and slug names:
通常,URL 是使用 ID 设计的:
Usually, URLs are designed using the ID:
"/products/[product-id]"
example: /products/213
但是它们对 URL 中的确切内容的描述太少(我的意思是,不同的 URL 将具有不同的 ID,但仅凭这一点 - 仅通过查看它 - 不会为您提供有关该特定 URL 的任何信息.)
But they are too little descriptive about what's exactly in that URL (I mean, different URLs will have different IDs, but this alone - just by looking at it - will not give you any information about that specific URL.)
Botoom line:只有 ID 不好,因为它没有多少描述性.
Botoom line: ID-only is bad because it is little descriptive.
使用:
"/products/[product-name]"
example: /products/three-legged-walking-oven
其实还不错,但需要注意的是:
Is actually pretty good, the caveats are:
- 您打算如何将
[product-name]
映射到[product-id]
? - 标题(或
[product-name]
)变化很大,如果有人为旧标题添加书签怎么办?
- How are you going to map a
[product-name]
into a[product-id]
? - Titles (or
[product-name]
) change a lot, what if someone bookmarks an old title?
使用:
"/products/[product-id]/[product-name]"
example: /products/213/three-legged-walking-oven
or
"/products/[product-id]-[product-name]"
example: /products/213-three-legged-walking-oven
在这种方法中,您通过 URL 的 id
部分获取产品.
In this approach, you get the product by the id
part of the URL.
为您提供两全其美:描述性网址和易于映射的网址和标题(名称)可以在不使旧网址无用的情况下进行更改.
Gives you the best of both worlds: descriptive urls AND easy to map urls AND titles (names) can change without making old URLs useless.
因此,如果您 100% 确定永远不会更改产品名称,则可以继续使用产品名称".只需找到一种方法以有效的方式将该产品名称"映射到产品 ID"即可.
So, if you are 100% certain you'll never change your products' name, you can go on and use "product-name". Just find a way to map that "product-name" into a "product-id" in an efficient way.
奖励:请务必查看这篇不错的文章 关于使用 slug 名称和搜索引擎的重要性.
Bonus: Make sure you check out this nice article about the importance of using slug names and search engines.
这篇关于URL 样式:为什么我应该使用 ids+slug 名称(“/products/[id]-[product-name]")而不是仅使用 slug 名称(“/products/[product-name]")?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!