What makes a “friendly URL”?

2019-01-10 01:34发布

I've read a great deal of discussion recently (both on this site and elsewhere) about "friendly URLs" but I'm not sure what exactly makes a URL "friendly" and why we really even care (up to a certain point). Illustration:

The following is an example of a URL that would be held up by the majority of current web developers as "friendly":

www.myblog.com/posts/123/this-is-the-name-of-my-blog-post

Whereas this would be considered "unfriendly" (i.e. bad, Neanderthal, ignorant, stupid):

www.myblog.com/posts.aspx?id=123

My questions:

  • Doesn't the "friendly" URL contain duplicate identifying information about the blog post in question? In other words, once you have the id (123) of the post, why do you need the title? Wouldn't this be a violation of the "don't repeat yourself" mantra?
  • What difference does the form of a URL make as far as users are concerned? Do users ever actually type full URLs by hand (other than the TLD, of course)? Do users ever look to the URL of a page to determine what the page is about? Why do we need the title of the blog post in the URL? Isn't that what the page's <title> tag and content are for?
  • I often hear SEO as a reason why the "friendly" URL form is preferred. Why does a search engine spider care about the URL? Aren't they just automated pieces of software that crawl pages (and the links to other pages that are contained within them)? If search engines were written like other software components (e.g. database access components), the URL would just be a meaningless identifier (similar to a rowguid in a relational database) to them. If I were designing a database schema with something like the "friendly" URL above as a table's primary key, I would (quite correctly) get chewed out.

I said earlier "up to a point" because obviously, URLs can get out of hand. Here is an actual URL from Amazon.com that I don't think anyone in their right mind would consider "friendly":

http://www.amazon.com/Bissell-Kitchen-Housewares/b/ref=amb_link_5001972_17?ie=UTF8&node=694500&pf_rd_m=ATVPDKIKX0DER&pf_rd_s=gp-center-5&pf_rd_r=1ZXNJFE0CCFFDH4B9HGH&pf_rd_t=101&pf_rd_p=405478901&pf_rd_i=510080

19条回答
你好瞎i
2楼-- · 2019-01-10 02:13

In this situation, it doesn't really break the DRY principal, because as far as a search engine is concerned, '522466' is not the same thing as 'what-makes-a-friendly-url'

Generally for sites like StackOverflow, the token is the only piece of information that matters; usually you can put whatever you want after that point and it'll take you to the same place (ignored by the web server).

The page description is only there to help the search engines identify what the page is about (which is nice)

查看更多
等我变得足够好
3楼-- · 2019-01-10 02:13

Matt and @bigmattyh: SEO is not "hacks": it's understanding what "good content" means on the web. Page titles are part of the content. Good anchor text in links is "good content" (rather than using words like "click here" as the link text). Placing links in context rather than as a list is "good content".

Page titles are low-hanging fruit, but they remain one of the easiest ways to improve SERP. Yes, inbound links (and their quality) are critical, but titles can do wonders, particularly in the short-term. You don't have to use the page title (which may change from time to time) as the post title: summarize the content manually.

Don't guess on this stuff: (a) read sources like SEOmoz.org and (b) analyze your own site rigorously.

查看更多
SAY GOODBYE
4楼-- · 2019-01-10 02:15

The 2nd URL looks more user friendly, whereas the first looks search-engine friendly.

Search engines give a higher relevance to words that appear in the URL. The domain name gets the highest (because it can't change), the rest of the URL gets a high priority because the length is limited, and then the body of the document is analysed.

My answer is quite subjective, because it depends on whether you are being human friendly (easy to type manually, or read to a friend) or whether you are being search engine friendly (boosting your ranking.)

查看更多
Animai°情兽
5楼-- · 2019-01-10 02:16

In my opinion, IDs and UUIDs should never be part of the URL, never.

1) Some NoSQL databases don't use IDs at all, they use UUIDs. UUIDs are long, portions are separated using dashes. Google will treat a dash like a words separator: that means your url will have 5 more useless keywords.

2) A human being does not understand IDs or UUIDs. A person understands words and talking URLs.

3) If the title changes you can simply make a redirect like WordPress does, like @TRiG pointed.

4) Finally, remember to use a date, so you can discern between two articles having the same title and posted in a different year, month or day. For example you can have two reviews (first edition and second edition) of the same book.

http://example.com/2013/02/11/data-mining-concepts-and-techniques

and

http://example.com/2011/05/23/data-mining-concepts-and-techniques

5) A date will also help any user to figure out if the content is recent or is not.

6) A date will add an important keyword to your URL: the year. Let's suppose I want see the most beautiful girls in the world, I will type in Google: "most beautiful girls in the world 2014". My url will be:

http://example.com/2014/07/10/the-most-beatiful-girls-in-the-world

7) Last but not least, Chrome caches the site you visited, so you can find the above site just typing in the address bar "girls".

查看更多
来,给爷笑一个
6楼-- · 2019-01-10 02:17

The term readable url is also used a lot. Using friendly/readable urls is a SEO born technique and that is about it. Otherwise the shorter the path the better.

查看更多
一纸荒年 Trace。
7楼-- · 2019-01-10 02:20

To me, friendly URL means there's been some attempt to include semantic information in the URL to make it more fit for human consumption. It's an interesting example of a computer-computer interface being augmented and built upon to make a better human-computer interface.

So, in your two examples:

  • www.myblog.com/posts/123/this-is-the-name-of-my-blog-post is friendly, because you've included the title in the URL - it tells you something about the page.
  • www.myblog.com/posts.aspx?id=123 is unfriendly because it's cryptic and obscure: it makes perfect sense to a database, but none to you or me.

Friendly URLs are fantastic in some situations and useless in others. Basically, if a user is ever going to be exposed to it, I'd make friendly URL creation a priority, and it's not just a matter of aesthetics. It makes it much easier to get back to URLs from the address bar if you can quickly see and understand what the various options are, plus it makes it more obvious where you're about to go if you're following a link from a web page.

Combine all that with the awesome bar in Firefox 3+ (surely coming in other browsers too), and auto-complete in the address bar becomes incredibly powerful when you're dealing with friendly URLs.

查看更多
登录 后发表回答