views:

411

answers:

8

In short, why use something like http://stackoverflow.com/badges/6/supporter instead of something "simpler" (and subjectively, at that) like http://stackoverflow.com/badges/6/.

Even on my own site I've just been using /post/6/ to reference posts (by IDs, even though I still store a slug.) Instead of /post/6/small-rant-on-urls, and in some cases, they can get even more absurd, much more so than is really necessary.

+20  A: 

Search Engine Optimisation would be one, as well as making the URL more readable to humans. Search engines generally like your URL, Title and H2 to contain the "topic" of the page.

If you have both in there then you can manually type /ID and get automagically taken to the "flowery" URL with rewriting.. saves your fingers a bit :)

Steven Robbins
I thought about doing something like that but haven't decided to how to go about implementing it. Though the only problem would be trying to give "fancy" URLs out to search spiders and keep URLs the same for normal visitors.
hydrapheetz
I don't think you need to give out "normal" URLs to visitors, as most people won't manually type URLs in, but being able to just put /Id is useful for yourself and any geeky power users that like to type :)
Steven Robbins
As ever.. I wish people would comment when they neg.
Steven Robbins
+3  A: 

Adding the slug in all links to the content helps with search engines, because search engines will generally use words in the URL itself to help index content.

Greg Hewgill
+1  A: 

@Greg Hewgill

Adding the slug in all links to the content helps with search engines, because search engines will generally use words in the URL itself to help index content.

I should have clarified a bit: I meant URLs that have both an id and slug in them. I just don't see the point in having something like /post/1/la-la-la-la-text-hahahaha vs /post/1/ or /post/la-la-la-la-text-hahahaha, since the first one would work without the extranous text at the end.

hydrapheetz
Oh I see what you mean. I find it convenient to be able to use (on SO) just the post ID to enter into the URL. Also, if the server ignores the slug then you can change the title of the question and inbound links will still work.
Greg Hewgill
+2  A: 

The reason for including the id in the url is that it makes it easier behind the scenes to retrieve the correct article from the database, as a lookup can be performed on the ID rather than the article's title.

The reason for including the full title of the article, is that Google gives heaps of bonus points for search terms that are matched in the filename.

cbp
+5  A: 

Because you can potentially end up with duplicates if you're not careful. I imagine stack overflow added the ID because there was a high potential for duplicates given the volume of posts created.

Other systems may choose not to use the ID in the URL - for example, a blogging system probably would not need to.

It's a better idea if you have user generated content that results in a new URL created to include a post ID. If the only way new URL's can be created is through administrator type access, you can probably do without it as long as you check for duplicates.

Andy Baird
A: 

It could be that is faster to get the post in a blog by the id than by the slug, so put the id for the SQL query and the slug for the search engines (SEO).

http://stackoverflow.com/users/58163/movaxes65675

I like the /post/la-la-la-la-text-hahahaha type, i can remember the url, know what the title of the post is (before actually loading the site). Don't like much the /post/1/ it means nothing to me but post #1 (bad for marketing?)

edit: id also helps to avoid duplicates as andybaird pointed

Movaxes
+1  A: 

URL is part of the Web user interface.

There is an eyetracking study of search engine use that found that people spend 24% of their gaze time looking at the URLs in the search results.

Searchers are particularly interested in the URL when they are assessing credibility and usefulness of a destination. If the URL looks like garbage, people are less likely to click on that search hit. On the other hand, if the URL looks like the page will address the user's question, they are more likely to click.

Roberto Russo
A: 

Well, firstly it should be pointed out that the "Web 2.0 style URLs" are actually part of something called REST. Those URLs are sometimes called RESTful URLs. The claimed benefits are:

  • Provides improved response time and reduced server load due to its support for the caching of representations;
  • Improves server scalability by reducing the need to maintain session state. This means that different servers can be used to handle different requests in a session;
  • Requires less client-side software to be written than other approaches, because a single browser can access any application and any resource;
  • Depends less on vendor software and mechanisms which layer additional messaging frameworks on top of HTTP;
  • Provides equivalent functionality when compared to alternative approaches to communication;
  • Does not require a separate resource discovery mechanism, due to the use of hyperlinks in representations;
  • Provides better long-term compatibility and evolvability characteristics than RPC. This is due to:
    • The capability of document types such as HTML to evolve without breaking backwards- or forwards-compatibility; and
    • The ability of resources to add support for new content types as they are defined without dropping or reducing support for older content types.
cletus