如何构建一个过滤干净 URL 的列表以提高可用性和 SEO?

发布于 2024-08-10 02:20:20 字数 563 浏览 8 评论 0原文

我非常支持对所有页面和列表使用超级干净的网址。一般来说,我的分页网址只是 example.com/section/page/2,标签是 example.com/tags/tagname。我通常甚至尝试将行 ID 排除在 url 之外。

但是你们建议如何做一个过滤列表呢?

假设您有一个汽车列表,并且想要按类型、颜色、价格或这些的组合进行排序。假设您想过滤列表以获取所有绿色轿车。

对我来说最有意义的是:

example.com/cars/?color=green&type=sedan&order=price

它看起来一点也不好看......不过我可以很好地阅读它。

但是..

example.com/cars/green/sedan/price 

没有任何意义。此外,尝试为此找出路由方案也是一件很麻烦的事。

另外,这如何与 SEO 配合使用?谷歌会在之后抓取吗?如果它爬行或不爬行参数,那很好吗?谷歌索引相同数据的无限排列会产生不良影响吗?

I am a big proponent of using super clean urls for all pages and lists. Generally my pagination urls are just example.com/section/page/2 and tags are example.com/tags/tagname. I generally even try to leave the row id out of the url.

But how would you guys suggest doing a filter list?

Say you have a list of cars and you want to sort by a type, color, price or a combination of those. Say you want to filter the list to get all sedans that are green.

It makes the most sense to me just to:

example.com/cars/?color=green&type=sedan&order=price

It doesn't look very nice at all... I can read it just fine though.

But..

example.com/cars/green/sedan/price 

doesn't make any sense. Also it would be a mofo to try to figure out a routing scheme for this.

Also how does this work with SEO? Will google crawl after the ?. Is that good if it does or doesn't crawl the params? Would google indexing endless permutations of the same data have ill effects?

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

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

发布评论

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

评论(6

风追烟花雨 2024-08-17 02:20:20

我见过一些在干净 URL 中使用命名参数的方案。例如:

example.com/cars/color:green/type:sedan/order:price
example.com/cars/page:2

实现它的代码可能有点棘手,但对于用户来说很容易理解。

I've seen a couple of schemes that use named parameters in the clean URL. For example:

example.com/cars/color:green/type:sedan/order:price
example.com/cars/page:2

The code to implement it can be a little tricky, but it's easy to understand for the user.

数理化全能战士 2024-08-17 02:20:20

当你有一个列表时,它应该只被谷歌索引一次。还记得“重复内容”吗?

所以一般来说我不建议在谷歌中拥有过滤列表。 (但也许它适合您的服务)

我避免对filterparams使用干净的url,并且在我的robots.txt中我用queryparams阻止所有url。

when you have a single list it should only be index by google once. remember "duplicate content"?

so generally i would not suggest to have the filtered list in google. (but maybe it fits to your service)

i avoid to use clean urls for filterparams and in my robots.txt i block all urls with queryparams.

晚风撩人 2024-08-17 02:20:20

主要要考虑的是,当用户想要找到所有轿车,但不关心颜色时会发生什么?

就我个人而言,我会按照字段的“高级”程度对字段进行排序,就好像它们是类别一样。例如,先放置类型,然后再放置颜色。任何仅改变您查看数据的方式的变量(例如排序)都保留在查询字符串中。

所以你最终会得到这些:

所有轿车:example.com/cars/sedan
所有绿色轿车:example.com/cars/sedan/green
轿车,已订购:example.com/cars/sedan?order=price
绿色轿车,已订购:example.com/cars/sedan/green?order=price

The main thing to think about is what happens when the user wants to find all sedans, but doesn't care about the colour?

Personally I would order the fields by how "high level" they are, as if they are categories. For example, put the type first, then maybe the colour. Any variables that only change the way you look at the data, like ordering, keep in the query string.

So you'd end up with these:

All sedans: example.com/cars/sedan
All green sedans: example.com/cars/sedan/green
Sedans, ordered: example.com/cars/sedan?order=price
Green sedans, ordered: example.com/cars/sedan/green?order=price

滥情稳全场 2024-08-17 02:20:20

谷歌很早就开始使用查询字符串抓取动态页面。所以一个“?”对于 Google 来说,在 URL 中不是问题。

我们使用干净网址的原因并不是因为搜索引擎不喜欢它。干净的网址是为用户设计的。因此,如果您只关心 SEO,请不要担心,请不要担心。

Google have long started crawling dynamic pages with query strings. So a '?' in an URL is not a problem for Google.

the reason we use clean urls is not because search engines don't like it. Clean urls are meant to be for the users. So don't sweat if all you are concerned about is SEO, don't sweat it.

一个人的夜不怕黑 2024-08-17 02:20:20

这又如何与 SEO 配合使用?谷歌会在之后抓取吗?

通常情况下,会的。

抓取参数是否好?

这由你决定,不是吗?我可以想象,许多一般查询最好包含在索引中,而大量非常详细的查询则不应该包含在索引中。也许您想准备一些要索引的查询并阻止所有其余查询。

Also how does this work with SEO? Will google crawl after the ?.

Normally, it will.

Is that good if it does or doesn't crawl the params?

That's up to you to decide, isn't it? I could imagine a number of general queries that would be good to have in the index, and a great number of very detailed ones that would not. Maybe you want to prepare a few queries to be indexed and block out all the rest.

若能看破又如何 2024-08-17 02:20:20

如果您反对纯粹是 SEO 和索引,则不要更改您的 URI 地址。相反,请使用规范链接标签并点赞您希望索引的页面地址。规范链接标签受到所有或很快将受到主要搜索引擎的支持,并防止对具有不同 URI 地址的同一页面进行冗余索引。

<link rel="canonical" href="http://example.com/cars/green/sedan/price" type="text/html"/>

type 属性不是必需的,但我发现在所有请求或定向媒体上指示 mime 类型通常是一个很好的做法。

If you object is purely SEO and indexing then do not alter your URI addresses. Instead use the canonical link tag and like to the address of your page that you wish to be indexed. The canonical link tag is supported by all, or soon will be, major search engines and prevents redundant indexing of the same page with different URI addresses.

<link rel="canonical" href="http://example.com/cars/green/sedan/price" type="text/html"/>

The type attribute is not required, but I find it is generally good practice to indicate mime types on all requested or directed media.

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