I'm confusing to choose my clean URL format for better SEO. Here are my two options:

  1. example.com/apple
  2. example.com/123/apple

The first format is very clean. It would be much more familiar and easier to read for search engine users. But I need to query the content from db using slug - "apple" in this case.

The second format uses a numeric ID of the content from db - "123" for the title "apple". It would be less familiar to users. But I can query the content from db using ID. This will make more efficient from the speed perspective.

The StackExchange questions use the second format like


But it has the very good SEO. I notice Google crawls questions fastly and they are listed in the first SERP in a very few hours.

Both SEO and speed is important for my site. Please suggest me what is the best option.


4 Answers 4


Remember, there's ALOT more to seo than the URL. If you have 'apple' in there and it's a relative term, great, you have a SEO friendly URL in my opinion.

Ideally, your whole URL would be relevant.

What does '123' correspond too? It might be worth displaying what it references (for example 'foods') in the URL instead of the number, but ONLY if it is of relevance to your page (e.g. if your page mentions foods, links to a foods page, etc.

As a rule of thumb, make your URL SEO friendly but not at the cost of its relevance to your page.

  • Please consider that "apple" is a blog title and "123" is the blog id (primary key field) in the db.
    – Sithu
    Commented Jan 21, 2014 at 15:22
  • 1
    The page title should be unique, if you have multiple pages with the same title, Then change the URL, like /article/apple and /gallery/apple, the page can have a slug column, which is used to then look up the row and id from the pages url without needing the ugly ID in the url.
    – S..
    Commented Jan 21, 2014 at 15:39
  • In this question URL, "57300" would be a primary key ID for the slug "what-is-the-best-practice-to-have-a-number-in-the-clean-url-or-not". That is I mentioned in my question.
    – Sithu
    Commented Jan 21, 2014 at 15:55
  • Yes, so use the slug as the primary ID instead? If you can't do that due to duplicate page titles then you have badly SEOd titles and that's more of a problem for you to focus on. You basically want search engines to think each page on your site serves a unique purpose. So have unique page URLs with matching relevant content.
    – S..
    Commented Jan 21, 2014 at 19:12

No doubt /apple is better than /apple-123 or any variations.

When you have /apple in your URL, you are saying your page is 100% relevant to apple. When you have /apple/123, you are saying apple is only 50% relevant to your page. When bot engines search for "apple", your URL will certainly weight more when the bots decides who must appear first.

The drawback of having only /apple in the URL, as yourself has pointed out, it will increase your CPU usage. For sure is very faster for your db engine to look for an integer as primary key than search for any unique text indexed.

I have done it already before and, in my case, the gain with SEO was worth the CPU increase since I saw noticeable gain with the SEO.


URLs should be:

  • short
  • memorable
  • type-able
  • descriptive
  • relevant to the content of the page

The number in the URL makes them longer, less memorable, and less type-able. It doesn't add to their descriptiveness nor relevance.

If you can make your URL have one, two, or three words; then I would recommend omitting the number. /blue-widets would be a great URL for a page about "blue widgets".

On the other hand, longer URLs have a tendency to break in ways that having a database ID helps with:

  • URLs longer than 80 characters often get truncated in emails and by CMS systems such as forum software
  • URLs that are based on the page title change every time the page title is altered
  • URLs based on user entered data can often be not unique

IDs in the URL help in those cases by uniquely identifying content. The server can much more easily adapt when the URL is mangled or changed:

  • Truncated URLs can be rebuilt as long as the ID is near the beginning of the URL and not in the portion at the end that got lopped off
  • When page titles change, it is easy to redirect to the new URL when the ID is available as a lookup

On the technical side, when IDs are present in the URL, the server needs to implement some form of URL canonicalization. Otherwise the same content can be served from multiple versions of the URL. This might happen, for example, when the page title changes. This can cause duplicate content problems that hurt search engine rankings.


My suggestion is to use second type of URL example.com/123/apple.
The first reason is: It is not more much worst than first and it is enough memorable.
The second reason is: Site performance speed become more and more important metric for search engines and, of course, for users.

  • 1
    Why is that a faster solution? If the DB is indexed properly then there shouldn't be a problem. Speed is taken into account by Google but still a tributary factor and I think SEO penalties for speed are for more than milliseconds. Look to optimise client side speed (downloads http compression etc) that affect mobile platforms for speed SEO.
    – S..
    Commented Jan 21, 2014 at 19:08
  • Understood your position. I have come from the fact, that "This will make more efficient from the speed perspective." So, if it is better for @Sithu in some cases, I do not see any problems with example.com/123/apple instead of example.com/apple. Commented Jan 22, 2014 at 12:14
  • Is a random number <i>really</a> memorable ?
    – S..
    Commented Jan 23, 2014 at 9:59
  • The primary goal of SEO-friendly URLS are not to be memorable, but to show user what is page about. Answering you question, it is enough memorable to remind, that I was watchig page about "apple". Commented Jan 23, 2014 at 11:14

Your Answer

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

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