17

I would like to know what's the best location for an ID in a SEO optimized URL:

http://www.example.com/123/slug-title

http://www.example.com/slug-title-123

2 Answers 2

9

Look no further then the URL of this page:

http://webmasters.stackexchange.com/questions/16641/seo-urls-best-place-for-the-id

It's in the http://www.site.com/action/id/slug-title format. But truthfully, both work well and are optimized for the search engines.

3
  • 1
    Thanks for your answer I was just wondering if this way un-needed weight is given to the id
    – mnml
    Jul 10, 2011 at 16:43
  • 6
    @mnml I recommend option #1 as well -- 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).
    – LazyOne
    Jul 10, 2011 at 16:52
  • 8
    This answer contains no references or documentation. (other than the assumption that SO must be doing it correctly?)
    – Kirk Woll
    Aug 27, 2012 at 18:19
3

Put the id near the beginning. I had some URLs with ids near the end and it caused a problem. Sometimes URLs get truncated. This is especially true when they are shown in the page and not linked.

Your website can probably figure out what to show if the link is

example.com/12345-this-is-the-whole-title-o...

but might not be able to in the case that the id is in the part that was truncated.

example.com/this-is-the-whole-title-of-the-...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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