0

Possible Duplicate:
Why do some websites add “Slugs” to the end of URLs?

This is not a question about stackoverflow, it's a question about a design decision which stackoverflow implements, and I take it as example.

A question on stackoverflow is identified by the following URL (took one from the suggestions)

https://stackoverflow.com/questions/363292/why-is-visual-c-lacking-refactor

Similarly, my user URL is:

https://stackoverflow.com/users/78374/stefano-borini

fact is, only the numeric index is actually used

https://stackoverflow.com/users/78374/

The remaining part can be anything. What is the reason behind such design decision, in particular considering that "cool URIs do not change"

Edit: voting for close after I saw this question which substantially puts the same issue forward. My question is a duplicate

Community
  • 1
  • 1
Stefano Borini
  • 138,652
  • 96
  • 297
  • 431
  • It lets you do things like (mouse over for tooltip) http://stackoverflow.com/questions/1534161/hide-more-information-in-comment-URLs – Greg Hewgill Oct 07 '09 at 21:05

8 Answers8

3

Part of the reason is so you can change your user name or the title of the post (correcting spellings etc.) but leave the URL valid.

It makes SEO sense to have the title in the URL - it makes it a lot more likely that the site will get indexed correctly.

ChrisF
  • 134,786
  • 31
  • 255
  • 325
1

It allows the URL to contain some interesting information for humans and search engines, but still works even if the title changes.

You could store the original "slug" in the database and verify against that as well as the id, but the only thing it prevents is games like this:

Lack of invariance in stackoverflow URL. Why?

:)

Community
  • 1
  • 1
Paul Dixon
  • 295,876
  • 54
  • 310
  • 348
0

Search engines like text in URLs.

Pages are given higher rank when the search terms actually appear in the URL rather than just the page. It's robot sugar, basically.

snicker
  • 6,080
  • 6
  • 43
  • 49
0

This allows you to see in the url some text which means something to you. If I look in a history of links a bunch of questions, the number alone would be meaningless. However, having the text there allows me to have some context.

Anthony Potts
  • 8,842
  • 8
  • 41
  • 56
0

This is SEO (search engine optimization) in action. It helps with the ranking of pages in search results (on google, yahoo, bing, ...), because search engines give higher rankings to pages which URL's contain keywords the user is searching for.

Jan Hančič
  • 53,269
  • 16
  • 95
  • 99
0

Theoretically, it's for SEO reasons. The software ignores the part following the identifier (the "slug"), but the idea is that search engine crawlers consider the description part of the link text, and thus weigh the resulting page higher in search results. Whether this actually happens in any meaningful way, I don't know for sure.

A more practical use is that you can gain a better idea of where a link's pointing just by inspecting the slug, which is handy if you've got multiple question URLs.

Rob
  • 47,999
  • 5
  • 74
  • 91
0

In addition to the benefit for Search Engines (the text in the URL is powerful), the fact is for all practical purposes this URL does not "change". A change can be defined as something which causes a link at some point in the future not to work - this would never be the case with this URL. The varying text at the end does not affect any user's ability to access the underlying resource.

aronchick
  • 6,786
  • 9
  • 48
  • 75
0

"cool URIs do not change"

Cool URIs can change, as long as the old ones are still fine.

Maybe someone will decide that “Lack of invariance in stackoverflow URL. Why ?” is a bad question title, and change it to “Why is there redundant information in SO URLs?”. It would be good if the slug can update to reflect the new title, especially if the reason we wanted to change it was an embarrassing typo. But the old URI must continue to work.

One drawback to non-canonical URIs is that search engines can get confused and think they're two different pages. Or they'll spot that they're two pages the same, but decide that the ‘best’ page to link to is the one with the title you don't want. This is especially bad if lots of people link to another title completely like:

http://stackoverflow.com/questions/1534161/stackoverflow-smells-of-poo

cue more embarrassment. The best way around this (though few sites bother, and SO doesn't) is to check the slug on submission and do a 301 permanent redirect to the new URI with the up-to-date slug instead. Search engines will pick up the new URI and not any malicious one with poo in it.

bobince
  • 528,062
  • 107
  • 651
  • 834