基于用户生成的内容设计 URI 的最佳方式 [英] Best way to design URIs when they are based on user generated content

查看:18
本文介绍了基于用户生成的内容设计 URI 的最佳方式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我们的系统中,我们有页面 URL,其中的内容(包括标题)基于用户生成的内容.我正在尝试找出平衡 SEO、人类可读性和弹性的最佳设计.

In our system, we have URLs for pages where the content, including the title, is based on user generated content. I'm trying to figure out the best design that balances SEO, human readability and resiliency.

我一直在阅读大量关于此的材料,包括 Tim Berners-Lee 的文档:酷 URI 不会改变.

I've been reading a bunch of material on this, including Tim Berners-Lee's document from way back: Cool URIs don't change.

举个例子,假设我有一个书评网站,用户在其中提交内容(文字评论)以及书名和作者.

As an example, imagine I have a book review site where users are submitting content (a worded review) and the book's title and author.

因此,如果他们与 Charles Dickens 的作者一起提交了对 A Tale of Two Cities 的书评(用户无意中拼错了).网址可以是:

So if they submitted a book review for A Tale of Two Cities (user unintentionally mispells it) with Author of Charles Dickens. The URL could be:

http://foo.com/charles-dickens/a-两个城市的故事

稍后,如果添加狄更斯的另一本书,则可能是:

Later on, if another book by Dickens is added, it could be:

http://foo.com/charles-dickens/oliver-twist

然后 http://foo.com/charles-dicens/ 可以是网站上所有已评论书籍的列表.

Then http://foo.com/charles-dickens/ could be a list of all the reviewed books on the site.

但是,如果更改书名,问题就会出现.想象一下用户拼错了一些东西,比如A Tale of Two City,然后它被纠正了.这也会更改 URL,并会破坏指向该页面、pagerank 等的任何外部链接.

However, the problem comes into play if a change is made to book title. Imagine the user mispelled something, like A Tale of Two City, then it's later corrected. This would also change the URL and would break any external links to that page, pagerank, etc.

处理此类问题的推荐方法是什么?我看到的选项:

What is the recommended way to handle this type of problem? Options I see:

  1. 首次提交获胜:URL 在最初建立后无法更改

  1. First commit wins: No changes to URL are possible after it's initially established

上次提交获胜: 始终更改 URL.因此,如果用户生成的内容发生更改,请修改 URL.使用这种方法,要么旧的 URL 已失效,要么保留所有 URL 更改的踪迹,并且所有这些更改仍然有效.Stackoverflow 似乎对此表示认同.

Last commit wins: Always change the URL. So if there's a change to the User generated content, revise the URL. With this approach, either the old URL is dead or a trail is preserved of all the URL changes and all of them still function. Stackoverflow seems to to this.

不要基于 UGC 的 URL: 忽略用户生成的内容,只是想出不是基于它的 URL.所以 url 可以是 http://foo.com/reviews/1234.

Don't base URL on UGC: Ignore the user generated content and just come up with URLs not based on it. So url could be http://foo.com/reviews/1234.

人们对此有何看法?

推荐答案

你说的有点不对;Stack Overflow 结合了 #2 和 #3.一个问题有一个特定的 id,这就是您定位问题所需的全部内容.例如,这个问题的 id 是 11011252.您可以通过https://stackoverflow.com/questions/11011252访问问题,无需添加从问题标题生成的 URL 部分(或者在这种情况下您将其称为 URI?).事实上,当您使用无标题地址时,它会自动添加(无论是通过重定向还是其他方法).

You're slightly wrong; Stack Overflow combines #2 and #3. A question has a specific id, and that's all you need to locate the question. For example, this question's id is 11011252. You can access the question with https://stackoverflow.com/questions/11011252, no need to add the portion of the URL (or would you call it a URI in this case?) generated from the question title. In fact, that will get automatically tacked on (whether by redirect or some other method) when you use the titleless address.

更好的是,您可以将任何您想要的内容(我想是在合理范围内)附加到地址的末尾.https://stackoverflow.com/questions/11011252/this-text-will-be-ignored 将带您毫无问题地回答问题.

Even better, you can append whatever you want (within reason, I suppose) to the end of the address. https://stackoverflow.com/questions/11011252/this-text-will-be-ignored will take you to the question without any problem.

Stack Overflow 也不是唯一这样做的网站;我见过的许多其他专注于用户生成内容的网站都遵循相同的协议/无论你怎么称呼它.这似乎是最好的方法,因为它结合了 #3(底层 URI 保持不变)的优点和 #2 的优点(URL 包含有关其目标的一些信息,用户会喜欢),以及最好的这意味着如果两个人使用相同的非唯一标识符生成内容,您将不会遇到任何 URI 冲突.

Stack Overflow isn't the only website that does this, either; many other sites I've seen focused on user-generated content follow the same protocol/whatever you call it. It seems like the best method to go with, as it combines the advantages of #3 (underlying URI remains the same) with the advantages of #2 (the URL contains some information about its target, which users will like), and best of all means you won't get any URI conflicts if two people generate content with the same non-unique identifiers.

这篇关于基于用户生成的内容设计 URI 的最佳方式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆