在页面 URL 中强制使用 slug 吗?

发布于 2025-01-03 23:44:22 字数 405 浏览 5 评论 0原文

我正在决定是否强制使用 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 技术交流群。

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

发布评论

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

评论(4

单挑你×的.吻 2025-01-10 23:44:22

url 中的 slug 可以用于三个目的:

  1. 当没有 id 时,它可以充当内容键(您有一个 id,所以这个不适用)
  2. 当仅将 url 作为指向您网站的链接发布时,它可以让用户知道期待什么内容,因为他们在 url 中看到
  3. 它可以被搜索引擎用作排名信号(据我所知,谷歌目前不太使用 url 单词作为排名信号)

Slugs 可以产生问题:

  1. 网址是更长,更难输入,更难记住,并且经常被截断
  2. 它可能会导致同一页面有多个 url 以及内容重复的 SEO 问题

我个人不喜欢使用 slug,除非它可以成为内容键,因为它造成的额外问题。话虽如此,有多种方法可以处理重复内容问题。

什么都不做,让搜索引擎整理重复的内容

他们似乎一直在这方面做得更好,但我不推荐这样做。

使用规范标签

当用户访问内容的任何 url 时,他们应该获得如下规范标签:

<link rel="canonical" href="http://domain.com/category/id/1/slug-title-here" />

就 Google 而言,规范标签甚至可以存在于规范 url 本身上,指向其自身。不过,必应建议不要使用自引用规范标签。有关规范标记的详细信息,请参阅:http://googlewebmastercentral.blogspot.com /2009/02/specify-your-canonical.html

使用 301 重定向

在规范标签之前,避免重复内容的唯一方法是使用 301重定向。您的软件可以检查 url 路径,并将 slug 与正确的 slug 进行比较。如果它们不匹配,它可以发出 301 重定向,将用户发送到具有正确 slug 的规范 URL。堆栈溢出软件就是这样工作的。

所以这些 urls:

domain.com/category/id/1/slug-blah-foo-bar
domain.com/category/id/1/

将重定向到

domain.com/category/id/1/slug-title-here

唯一实际包含内容的 url。

The slug in the url can serve three purposes:

  1. It can act as a content key when there is no id (you have an id,so this one doesn't apply)
  2. When just a url is posted as a link to your site, it can let users know what content to expect because they see it in the url
  3. It can be used by search engines as a ranking signal (Google does not use url words as a ranking signal very much right now as far as I can tell)

Slugs can create problems:

  1. Urls are longer, harder to type, harder to remember, and often get truncated
  2. It can lead to multiple urls for the same page and SEO problems with content duplication

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:

<link rel="canonical" href="http://domain.com/category/id/1/slug-title-here" />

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:

domain.com/category/id/1/slug-blah-foo-bar
domain.com/category/id/1/

would redirect to

domain.com/category/id/1/slug-title-here

which would be the only url that would actually have the content.

任性一次 2025-01-10 23:44:22

假设您永远不会更改页面的 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) to domain.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.

你丑哭了我 2025-01-10 23:44:22

我建议你制作一个 rel=canonical 元标记。

这可以防止每次考虑到有人可以使用无限变体链接您的页面时进行重定向,如下所示:

domain.com/category/id/1/?fakeparam=1

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:

domain.com/category/id/1/?fakeparam=1
躲猫猫 2025-01-10 23:44:22

从 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.

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