为什么有些网站会在标题中添加“Slugs”? 到 URL 末尾?

发布于 2024-07-04 10:53:54 字数 1476 浏览 8 评论 0原文

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

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

发布评论

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

评论(14

温柔嚣张 2024-07-11 10:53:56

我注意到您可以自由更改文本。 这个 URL 看起来也同样有效。

https://stackoverflow.com/questions/47427/why-is-billpg -太棒了

I note that you can change the text freely. This URL appears to work just as well.

https://stackoverflow.com/questions/47427/why-is-billpg-so-very-awesome

梦在深巷 2024-07-11 10:53:56

如前所述,“slug”可以帮助人们和搜索引擎...

值得注意的是,在页面的源代码中有一个 规范网址

这会阻止页面被多次索引。

例子:

<link rel="canonical" href="http://stackoverflow.com/questions/47427/why-do-some-websites-add-slugs-to-the-end-of-urls">

As already stated, the 'slug' helps people and the search engines...

Something worth noticing, is that in the source of the page there is a canonical url

This stops the page from being index multiple times.

Example:

<link rel="canonical" href="http://stackoverflow.com/questions/47427/why-do-some-websites-add-slugs-to-the-end-of-urls">
妄司 2024-07-11 10:53:56

删除问题中的格式,您将看到部分答案:

https://stackoverflow.com/questions/47427 /

https://stackoverflow.com/questions/47427/why-do-some-websites-add-slugs-to-the-end-of-urls

没有标记,第二个一种是自我描述的。

Remove the formatting from your question, and you'll see part of the answer:

https://stackoverflow.com/questions/47427/

vs

https://stackoverflow.com/questions/47427/why-do-some-websites-add-slugs-to-the-end-of-urls

With no markup, the second one is self-descriptive.

美人迟暮 2024-07-11 10:53:56

发送链接时不要忘记可读性,而不仅仅是在搜索引擎中。 如果您通过电子邮件向某人发送第一个链接,他们可以查看该 URL 并大致了解其内容。 第二个页面在点击之前不会显示该页面的内容。

Don't forget readability when sending a link, not just in search engines. If you email someone the first link they can look at the URL and get a general idea of what it is about. The second one gives no indication of the content of that page before they click.

笔芯 2024-07-11 10:53:56

如果您通过电子邮件向某人发送了一个链接,那么通过实际写出描述来包含描述不是更有意义,而不是让其他人解析到描述所在的 URL,然后尝试读取一堆内容-连字符的单词粘在一起。

If you emailed someone a link wouldn't it make more sense to include a description by actually writing out a description rather than making the other person parse to the URL where the description exists, and try-to-read-a-bunch-of-hyphenated-words-stuck-together.

≈。彩虹 2024-07-11 10:53:56

首先,它是 SEO 和用户友好的,但就示例(本网站)而言,它做得不好或不正确
(因为它容易遭受黑帽技巧和其他人的排名中毒,这会对该网站产生不良影响)。

如果

https://stackoverflow. com/questions/47427/why-do-some-websites-add-slugs-to-the-end-of-urls

有内容,然后

https://stackoverflow.com/questions/47427/

https://stackoverflow.com/questions/47427/any-other-bollix

不应重复。 他们实际上应该自动检测后面的链接不使用当前文本(显然,slug 是由问题标题定义的,可以稍后编辑),并且他们应该自动将 301 重定向到

https://stackoverflow.com/questions/47427/why-do-some-websites -add-slugs-to-the-end-of-urls

从而确保“一份内容到一个 URI”规则,并且如果 URI 移动/更改,请确保旧书签跟随/通过 301 重定向进行移动(因此智能浏览器可以更新书签)。

First off, it's SEO and user friendly, but in the case of the example (this site), it's not done well or correctly
(as it is open to black hat tricks and rank poisoning by others, which would reflect badly on this site).

If

https://stackoverflow.com/questions/47427/why-do-some-websites-add-slugs-to-the-end-of-urls

has the content, then

https://stackoverflow.com/questions/47427/

and

https://stackoverflow.com/questions/47427/any-other-bollix

should not be duplicates. They should actually automatically detect the link followed is not using the current text (as obviously the slug is defined by the question title and can be later edited) and they should redirect 301 automatically to

https://stackoverflow.com/questions/47427/why-do-some-websites-add-slugs-to-the-end-of-urls

thus ensuring the "one piece of content to one URI" rule, and if the URI moves/changes, ensure the old bookmarks follow/move with it through 301 redirects (so intelligent browsers can update the bookmarks).

掀纱窥君容 2024-07-11 10:53:56

理想情况下,“slug”应该是唯一需要的标识符。 实际上,在这样的动态网站上,您要么必须拥有唯一的数字标识符,要么像 Digg 那样开始向“slug”附加/递增数字。

Ideally, the "slug" should be the only identifier needed. In practice, on dynamic sites such as this, you either have to have a unique numerical identifier or start appending/incrementing numbers to the "slug" like Digg does.

伤痕我心 2024-07-11 10:53:55

我同意其他回复,即任何输入错误的 slug 都应该 301 重定向到正确的形式。 换句话说, https://stackoverflow.com/questions/47427/wh 应该重定向到 https://stackoverflow。 com/questions/47427/why-do-some-websites-add-slugs-to-the-end-of-urls 。 它还有一个尚未提及的好处——如果您不重定向到规范 URL,则会出现几乎无限数量的重复页面。 谷歌讨厌重复的内容。

也就是说,您实际上应该只关心内容 ID,并在重定向时允许 slug 的任何输入。 为什么?

https://stackoverflow.com/questions/47427/why-do-some- websites-add-slugs-to-the-end-of-urls

... 糟糕,邮件软件截掉了 URL 末尾! 不过没问题,因为您仍然可以使用 https://stackoverflow.com/questions/47427

这种方法的一个问题是,如果您从内容标题中派生出 slug,您将如何处理非 ASCII、UTF-8 标题?

I agree with other responses that any mis-typed slug should 301-redirect to the proper form. In other words, https://stackoverflow.com/questions/47427/wh should redirect to https://stackoverflow.com/questions/47427/why-do-some-websites-add-slugs-to-the-end-of-urls . It has one other benefit that hasn't been mentioned--if you do not do a redirect to a canonical URL, it will appear that you have a near-infinite number of duplicate pages. Google hates duplicate content.

That said, you should really only care about the content ID and allow any input for the slug as long as you redirect. Why?

https://stackoverflow.com/questions/47427/why-do-some-websites-add-slugs-to-the-end-of-urls

... Oops, the mail software cut off the end of the URL! No problem though because you still can roll with just https://stackoverflow.com/questions/47427

The one big problem with this approach is if you derive the slug from the title of your content, how are you going to deal with non-ASCII, UTF-8 titles?

横笛休吹塞上声 2024-07-11 10:53:55

大多数网站使用它的原因可能是 SEO(搜索引擎优化)。 雅虎过去常常对 URL 本身中搜索关键字的出现给予合理的权重,这对谷歌结果也有帮助。

最近,搜索引擎降低了 URL 中关键字的权重,可能是因为该技术现在在垃圾邮件网站上比合法网站上更常见。 现在,URL 中的关键字对搜索结果的影响非常小(如果有的话)。

至于 stackoverflow 本身,SEO 可能是一种动机(旧习难改)或仅仅是为了可用性。

The reason most sites use it is probably SEO (Search Engine Optimization). Yahoo used to give a reasonable weighting to the presence of the search keyword in the URL itself, and it also helped in the Google result as well.

More recently the search engines have lowered the weighting given to keywords in the URL, likely because the technique is now more common on spam sites than legitimate. Keywords in the URL now have only a very minor impact on the search results, if at all.

As for stackoverflow itself, SEO might be a motivation (old habits die hard) or simply for usability.

林空鹿饮溪 2024-07-11 10:53:55

它基本上是资源更有意义的位置。 使用 ID 是完全有效的,但它对机器的意义比对人的意义更大。

严格来说,如果 slug 是唯一的,则不需要 ID,您可以通过在日期内确定它们的范围来更轻松地确保唯一的 slug。

即:

/2008/sept/06/why-some-websites-add-slugs-end-of-urls/

基本上,这利用了同一天使用两个相同的 slugs 的可能性较低。 如果存在冲突,一般惯例是在 slug 的末尾添加一个计数器,但您很少看到这些:

/2008/sept/06/why-some-websites-add-slugs-end-of-urls/
/2008/sept/06/why-some-websites-add-slugs-end-of-urls-1/
/2008/sept/06/why-some-websites-add-slugs-end-of-urls-2/

许多 slug 算法还摆脱了诸如“the”和“a”之类的常见单词来协助保持 URL 简短。 这种范围化方法还使得查找给定日期、月份或年份的所有资源变得非常简单 - 您只需截取片段即可。

此外,stackoverflow URL 也很糟糕,因为它们引入了额外的段来展示 slug,这违反了每个段应代表资源层次结构的降序这一理念。

It's basically a more meaningful location for the resource. Using the ID is perfectly valid but it means more to machines than people.

Strictly speaking the ID shouldn't be needed if the slug is unique, you can more easily ensure unique slugs by scoping them inside dates.

ie:

/2008/sept/06/why-some-websites-add-slugs-end-of-urls/

Basically this exploits the low likelihood of two identical slugs being in use on the same day. If there is a clash the general convention is to add a counter at the end of the slug but it's rare that you ever see these:

/2008/sept/06/why-some-websites-add-slugs-end-of-urls/
/2008/sept/06/why-some-websites-add-slugs-end-of-urls-1/
/2008/sept/06/why-some-websites-add-slugs-end-of-urls-2/

A lot of slug algorithms also get rid of common words like "the" and "a" to assist in keeping the URL short. This scoped approach also makes it very straightforward to find all resources for a given day, month or year - you simply chop off segments.

Additionally, stackoverflow URLs are bad in the sense that they introduce an additional segment in order to feature the slug, which is a violation of the idea that each segment should represent descending a resource hierarchy.

画离情绘悲伤 2024-07-11 10:53:55

术语“slug”来自报纸/出版业。 这是一个简短的标题,用于标识正在进行的故事。 对 URL 语义感兴趣的人们开始在他们的 URL 中使用简短的缩写标题。 它在 SEO 领域也得到了回报,因为 URL 中的关键字增加了页面的重要性。

具有讽刺意味的是,许多网站已经开始在其 URL 中放置带有连字符的完整序列化版本的标题,以严格满足 SEO 目的,这意味着术语 slug 不再适用。 这也激怒了语义纯粹主义者,因为许多实现只是在 URL 末尾添加标题的序列化版本。

The term slug comes from the newspaper/publishing business. It's a short title that's used to identify a story in progress. People interested in URL semantics started using a short, abbreviated title in their URLs. It also pays off in SEO land, as keywords in URLs add importance to a page.

Ironically, lots of websites have started place a full serialized-with-hyphens version of the titles in their URLs for strictly SEO purposes, which means the term slug no longer quite applies. This also rankles semantic purists, as many implementations just tack this serialized version of the title at the end of their URLs.

巨坚强 2024-07-11 10:53:54

slugs 使 URL 更加用户友好,并且您知道单击链接时会发生什么。 如果搜索词在 URL 中,搜索引擎(例如 Google)会对页面排名更高。

The slugs make the URL more user-friendly and you know what to expect when you click a link. Search engines such as Google, rank the pages higher if the searchword is in the URL.

晌融 2024-07-11 10:53:54

可用性是原因之一,如果您在电子邮件中收到该链接,您就知道会发生什么。
SEO(搜索引擎优化)是另一个原因。 谷歌等搜索引擎会根据网址中包含的关键字对您的页面进行更高的排名

Usability is one reason, if you receive that link in your e-mail, you know what to expect.
SEO (search engine optimization) is another reason. Search engines such as google will rank your page higher for the keywords contained in the url

昇り龍 2024-07-11 10:53:54

我最近更改了我的网站网址格式:

www.mywebsite.com/index.asp?view=display&postid=100

www.mywebsite.com/this-is-the-title-of-the-post

并注意到更改后文章的点击率增加了约 300%。 就 SEO 目的而言,它确实可以帮助用户确定他们想要点击的内容是否相关,尽管我不得不说,更改后影响不大

I recently changed my website url format from:

www.mywebsite.com/index.asp?view=display&postid=100

To

www.mywebsite.com/this-is-the-title-of-the-post

and noticed that click through rates to article increased about 300% after the change. It certainly helps the user decide if what they're thinking of clicking on is relevant, in terms of SEO purposes though I have to say I've seen little impact after the change

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