在页面 URL 中强制使用 slug 吗?
我正在决定是否强制使用 slug 来查看提交的内容。
现在,这些工作中的任何一个都可以提交:
domain.com/category/id/1/slug-title-heredomain.com/category/id/1/slug-blah
-foo-bar
domain.com/category/id/1/
全部转到同一个提交。
您还可以将 slug 更改为您想要的任何内容,它仍然可以工作,因为它只检查类别、id 和提交 #(在第二个示例中)。
我想知道这是否是执行此操作的正确方法?从 SEO 的角度来看,我应该这样做吗?如果没有,我应该对请求没有 slug 的 URL 的用户做什么?
I'm deciding whether or not to make the slug mandatory in order to view a submission.
Right now either of these works to get to a submission:
domain.com/category/id/1/slug-title-here
domain.com/category/id/1/slug-blah-foo-bar
domain.com/category/id/1/
All go to the same submission.
You can also change the slug to whatever you want and it'll still work as it just checks for the category, id, and submission # (in the second example).
I'm wondering if this is the proper way to do this? From an SEO standpoint should I be doing it like this? And if not, what should I be doing to users who request the URL without the slug?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
url 中的 slug 可以用于三个目的:
Slugs 可以产生问题:
我个人不喜欢使用 slug,除非它可以成为内容键,因为它造成的额外问题。话虽如此,有多种方法可以处理重复内容问题。
什么都不做,让搜索引擎整理重复的内容
他们似乎一直在这方面做得更好,但我不推荐这样做。
使用规范标签
当用户访问内容的任何 url 时,他们应该获得如下规范标签:
就 Google 而言,规范标签甚至可以存在于规范 url 本身上,指向其自身。不过,必应建议不要使用自引用规范标签。有关规范标记的详细信息,请参阅:http://googlewebmastercentral.blogspot.com /2009/02/specify-your-canonical.html
使用 301 重定向
在规范标签之前,避免重复内容的唯一方法是使用 301重定向。您的软件可以检查 url 路径,并将 slug 与正确的 slug 进行比较。如果它们不匹配,它可以发出 301 重定向,将用户发送到具有正确 slug 的规范 URL。堆栈溢出软件就是这样工作的。
所以这些 urls:
将重定向到
唯一实际包含内容的 url。
The slug in the url can serve three purposes:
Slugs can create problems:
I am personally not a fan of using a slug unless it can be made the content key because of the additional issues it creates. That being said, there are several ways to handle the duplicate content problems.
Do nothing and let search engines sort out duplicate content
They seem to be doing better at this all the time, but I wouldn't recommend it.
Use the canonical tag
When a user visits any of the urls for the content, they should get a canonical tag like such:
As far as Google is concerned, the canonical tag can even exist on the canonical url itself, pointing to itself. Bing has advised against self referential canonical tags though. For more information on canonical tags see: http://googlewebmastercentral.blogspot.com/2009/02/specify-your-canonical.html
Use 301 redirects
Before canonical tags, the only way to avoid duplicate content would be with 301 redirects. Your software can examine the url path, and compare the slug to the correct slug. If they don't match, it can issue a 301 redirect that will send the user to the canonical url with the correct slug. The stack overflow software works this way.
so these urls:
would redirect to
which would be the only url that would actually have the content.
假设您永远不会更改页面的 slug,我只需设置
domain.com/category/id/1/
来执行 301 重定向(永久)到域。 com/category/id/1/slug-title-here
,并且任何时候有人输入与该文章不正确的slug (domain.com/category/id/1/slug-title-here-oops-this-is-wrong
),还将它们 301 到正确的地址。这样你就可以对搜索引擎说“我没有重复的内容,看,这是一个永久的重定向”,这样就不会损害你的搜索引擎优化,并且你对用户很有用,总是把他们带到正确的“友好网址”页面。
Assuming you're not ever going to change a page's slug, I'd just set up
domain.com/category/id/1/
to do a 301 redirect (permanent) todomain.com/category/id/1/slug-title-here
, and any time someone enters a slug which is incorrect for that article (domain.com/category/id/1/slug-title-here-oops-this-is-wrong
), also 301 them to the correct address.That way you're saying to the search engines "I don't have duplicate content, look, this is a permanent redirect" so it doesn't harm your SEO, and you're being useful to the user in always taking them to the correct "friendly url" page.
我建议你制作一个 rel=canonical 元标记。
这可以防止每次考虑到有人可以使用无限变体链接您的页面时进行重定向,如下所示:
I suggest you to make a rel=canonical meta tag.
This prevents do a redirect each time considering someone can link your page with infinte variant like this:
从 SEO 的角度来看,只要您只链接到这些 URL 的一个版本,就应该没问题,因为其他 URL 甚至不会被搜索引擎收录(因为没有任何链接到它们)。
但是,如果您链接到所有 3 个内容,则可能会损害您的排名(因为它将被视为重复内容)。
我个人不会要求 slug,但我会确保(在内部)所有链接都指向包含 slug 的 URL。
From a SEO standpoint, as long as your only ever linking to one version of those URL's, it should be fine as the other URL's won't even be picked up by the search engine (as nowhere links to them).
If however you are linking to all 3, then it could hurt your rankings (as it'll be considered duplicate content).
I personally wouldn't make the slug required, but I would make sure that (internally) all links would point to a URL including the slug.