Take the 2-minute tour ×
Webmasters Stack Exchange is a question and answer site for pro webmasters. It's 100% free, no registration required.

Take for example this random question Tool or plugin required to show out in which html files a given css selectors is used, notice that the relevant part is /questions/16999.

Now, it being possible that the url could have been done like this :

http://webmasters.stackexchange.com/questions/tool-or-plugin-required-to-show-out-in-which-html-files-a-given-css-selectors-is/16999`

That is the question_id is after the question, and what comes first in a url weighs more in seo, why is the question part coming after the question_id.

I also read in an article that only the first two subdirectories are relevant therefore only /question/16999 is relevant. Looking at SO this is definitely not true, but I can't decide on the weigh of this.

I am asking because I am going to implement seo optimizations and don't want to have to change the link to my pages afterwards.

share|improve this question
    
btw I wanted to add subdirectory as a tag –  andho Jul 17 '11 at 17:10
    
Paging @Jeff Atwood. (Might as well go to the sources.) –  Su' Jul 17 '11 at 17:37
1  
Sometimes URL can be truncated (intentionally (too long to store in DB etc) or by mistake) .. and if id is before slug, the server/script can still recognize the page you want but with id at the end it most likely will not. Try URL of this page -- remove last few characters and submit -- server will redirect you to the correct URL (apparently the code behind has special treatment for such scenario). With id at the end you possibly would see completely different question (or error page). webmasters.stackexchange.com/questions/16641/… –  LazyOne Jul 17 '11 at 17:57
    
@Lazyone, make that an answer so we can vote it up –  John Conde Jul 17 '11 at 19:41
    
If you leave off the last "directory" of the URL for this question, you still get this question: webmasters.stackexchange.com/questions/17002/foo-bar –  kzh Jul 17 '11 at 22:19

3 Answers 3

up vote 11 down vote accepted

I do not know exact reasons why StackExchange sites do have ID before slug, but here is why I would have it this way:

Sometimes URL can be truncated (intentionally (too long to store in DB etc) or by mistake (happens quite often when copy-paste)) .. and if ID is before slug, the server/script can still recognize the page you want but with ID at the end it most likely will not.

Try URL of this page -- remove last few characters and submit -- server will redirect you to the correct URL (apparently the code behind this site has special treatment for such scenario). With ID at the end you possibly would see completely different question (the most common behaviour in such case).. or just error page (when server/script ensures that slug matches ID).

With regards to SEO effect -- see this question: SEO : urls : best place for the id

share|improve this answer
1  
Good point about truncation +1 –  UpTheCreek Jul 19 '11 at 8:19

Yes, it's they could have added the ID after the question title if they had wished.

Regarding the position of the ID and SEO, in my opinion I don't think it would make any difference (ok maybe if it was in the domain name).

From a human readability point of view, it seems clearer (to me at least) to have the human readable title at the end, rather than burried in the URL.

I also read in an article that only the first two subdirectories are relevant therefore only /question/16999 is relevant. Looking at SO this is definitely not true, but I can't decide on the weigh of this

Where did you read this? I don't think it is correct, and nowadays these re-written URLs don't usually relate to subdirectories in any way.

share|improve this answer
    
I guess we will have to agree to disagree. For me, a random number (okay it's the question id) in the middle of the url is kinda awkward than something reading naturally like /question/what-did-you-have-for-lunch/mumble-jumble. Here I would just ignore everything starting from the mumble-jumble. –  andho Jul 18 '11 at 14:37
    
btw here is the link I read the thing about 2 subdirectories, goodwebsiteinspector.com/en/… –  andho Jul 18 '11 at 14:38
2  
yes, we will have to agree to dissagee :) I don't agree with the conclusions about 'subdiretories' in that link. These are usually not subdirectories at all, and google knows that. Even if it was, why would google downrate a potentially useful resource, just becuase it was 'deep'? –  UpTheCreek Jul 19 '11 at 8:18

The processing of the URL by the server is ignoring the portion of the URL following the question id number and slash. All of these are equivalent:

/questions/16999
/questions/16999/
/questions/16999/any-text-at-all

They all redirect to the URL having the (reformatted) question text after the slash.

This allows them to use the short form URL in links from one page to another (such as the links in the Related sidebar on this page), saving HTML transmission time as well as storage and cpu cycles. By having the question-text in the canonical URL (the one redirected to), they still get the benefits of having relevant text in the URL for use in search engine indexing.

share|improve this answer
    
I can't see any examples on SO where they use the shortened version of the URL. –  UpTheCreek Jul 18 '11 at 6:39

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.