42

I'd like to start using "SEO Friendly Urls" but the notion of generating and looking up large, unique text "ids" seems to be a significant performance challenge relative to simply looking up by an integer. Now, I know this isn't as "human friendly", but if I switched from:

http://example.com/products/details?id=1000

To:

http://example.com/products/spacelysprokets/sproket/id

I could still use the ID alone to quickly lookup the details, but the URL itself contains keywords that will display in that detail. Is that friendly enough for Google? I hope so as it seems a much easier process than generating something at the end that is both unique and meaningful.

Thanks!

Super Kai - Kazuya Ito
  • 22,221
  • 10
  • 124
  • 129
James White
  • 2,062
  • 2
  • 24
  • 36
  • 4
    Your question assumes that SEO is measurably beneficial, which it is not. – moo Sep 18 '09 at 01:07
  • Thanks for contributing an answer to Stack Overflow! Please make sure you answer the question; this is a Q&A site, not a discussion forum. Provide details and share your research. Avoid statements based solely on opinion; only make statements you can back up with an appropriate reference, or personal experiences. –  Jun 30 '11 at 13:02
  • 1
    its very amusing, in 2017, to look back on a comment that says "Your question assumes that SEO is measurably beneficial, which it is not". Oh boy, was it ever. In the last 8 years, people have made a *lot* of money from SEO being a huge commercial driver for success! – Andy Lorenz Jun 08 '17 at 15:30

12 Answers12

87

Be careful with allowing a page to render using the same method as Stack overflow.

http://stackoverflow.com/questions/820493/random-text-can-cause-problems

Black hats can this to cause duplicate content penalty for long tail competitors (trust me).

Here are two things you can do to protect yourself from this.

  • HTTP 301 redirect any inbound display url that matches your ID but doesn't match the text to the correct text.

Example: http://stackoverflow.com/questions/820493/random-text-can-cause-problems 301 -> http://stackoverflow.com/questions/820493/can-an-seo-friendly-url-contain-a-unique-id

  • Use canonical URLs.

<link rel="canonical" href="http://stackoverflow.com/questions/820493/can-an-seo-friendly-url-contain-a-unique-id" />

TRiG
  • 10,148
  • 7
  • 57
  • 107
Julian Sutter
  • 986
  • 6
  • 4
  • 1
    this is great advice! This really answers the question I was asking in a question here today. Thanks! – Evik James Sep 01 '11 at 20:58
  • Wouldn't it be ok to just stop after the ID in the canonical URI? – DanMan Jun 26 '14 at 22:49
  • @DanMan stopping after the ID would lose the benefits of having keywords in the indexable URL. – drmonkeyninja Jun 29 '15 at 10:44
  • "matches your ID but doesn't match the text" the whole point of using an id is not to have to rely on the text. So looking to match the text doesn't make much sense. – Zephyr was a Friend of Mine Jun 04 '18 at 13:33
  • 1
    "Black hats can this to cause duplicate content penalty for long tail competitors (trust me)." Do you have any sources on this? – danihodovic Aug 14 '19 at 15:11
  • 1
    @danihodovic: You can see why with a basic example: A competitor places a fake review on their site that points to your site with a mis-spelled product url. E.g.; they use href="www.site.com/products/koncrete-mixer/6868". Google then indexes this page and thinks it's duplicate content with your own link, "www.site.com/products/concrete-mixer/6868". No actual 'hacking' is required. – aphid Sep 11 '19 at 08:24
72

https://stackoverflow.com/questions/820493/can-an-seo-friendly-url-contain-a-unique-id

I'd say you're fine.

Community
  • 1
  • 1
Tom Ritter
  • 99,986
  • 30
  • 138
  • 174
  • 1
    Although note you get extra SEO points for having the title in the URL but you can omit to read it when extracting the product, article, etc. I think it's not as much as having an unique ID that's bad than having a description of the page you're opening that's good. – lpfavreau Sep 18 '09 at 01:08
  • i think this url structure is not the best for SEO? why? because the SE is highly recommended with the keyword , not the article ID, that's mean you should place article title for the first position is better for SEO. EX: domain.com/article-title/id – TomSawyer Sep 10 '13 at 12:51
  • 1
    @TomSawyer actually it's not recommended to place the id at the end, if it doesn't matter how your build your urls it does for your users to make them short and descriptive. So in this example the id should be considered as a folder and not as a file. – Mooncake Jan 27 '15 at 19:42
15

Have a look at the URLs that StackOverflow uses. They have a unique id, then they have the SEO-friendly stuff. You can omit the SEO-friendly stuff and the URL still works.

Paul Tomblin
  • 179,021
  • 58
  • 319
  • 408
5

You are making a devils bargan here, you are trading away business goals for technology goals.

If you were to ask "From a purely business and SEO prospective, is it better to include unique IDs in the URL or not?"; the answer would clearly be to not use them.

The question then becomes, if you do use them, how much does it hurt you in the search engines? The answer is that it definately has some negative impact. How much is yet to be determined.

In terms of "user friendly", no, they are definitely not user friendly.

In terms of Google, they state "Whenever possible, shorten URLs by trimming unnecessary parameters." See their URL structure document.

Michiel de Mare
  • 41,982
  • 29
  • 103
  • 134
JonnyBoats
  • 5,177
  • 1
  • 36
  • 60
  • 1
    And how do you comment that all URLs submitted to Google News *have to* contain a numeric ID? – viam0Zah May 04 '09 at 15:16
  • 1
    With respect to Google News, I guess my answer is that Google is Google so they can do anything they want. In other words you need Google more than Google needs you. Google treats "Google News" as a special case with different routines than standard websites. – JonnyBoats May 04 '09 at 18:15
  • If I can find more pertinent searches on Google as a result of meaningful SEO like shaping links, then that's a usability gain on the website -- technical enough in my book. – Rei Miyasaka Aug 06 '10 at 07:24
  • But if you dump the ID segment, you run the risk of having URLs like: http://stackoverflow.com/questions/820493/can-an-seo-friendly-url-contain-a-unique-id-1 and -2 and -3 and so on, which doesn't look professional. – Wayne Smallman May 31 '13 at 08:26
4

I'm not aware of any problems caused by adding an ID to a URL. In fact it can be extremely useful, as it allows the human/search engine friendly part of the URL to be changed without causing a broken link to a page that a search engine has already indexed. Using SO as an example, here's a link to your question:

https://stackoverflow.com/questions/820493/you-can-put-any-text-you-want-here

Community
  • 1
  • 1
Nick
  • 5,616
  • 10
  • 52
  • 72
1

I have two seemingly contradictory points to make here:-

  1. Nobody looks at URLs! Experience has "trained" browser users to render the "Address" box contents as invisable, they know the contents will be any two of 'ureadable', 'meaningless' and 'confusing', hence they just ignore it completely.

  2. Using a String which can be easily converted to an integer may offer a slight performance advantage over using a longer string which is slightly harder (hash() vs. to_int() ) to convert into an integer. However in the context of the average web application any performance difference would would be negligable.

My advice would be to stick with what your comfortable with.

James Anderson
  • 27,109
  • 7
  • 50
  • 78
1

Nothing wrong with that. An increasing number of services have started to use a hybrid solution as Paul Tomblin already pointed out. In addition to SO, Tumblr uses this pattern too (maybe it was the first).

Furthermore, in certain services—like Google News—the URL must contain a unique numeric ID.

Community
  • 1
  • 1
viam0Zah
  • 25,949
  • 8
  • 77
  • 100
1

Getting rid of the parameterized URL will definitely help. From my experience, including the ID does not hurt or help, as long as there are no '?key=value' pairs in the url.

ftank99
  • 51
  • 2
0

Duplicate refer cause more negative impact compare to friendly URL, be careful about using fake text with id, your competitors could miss use this.

Ehsan
  • 13
  • 4
  • you can always check it and 301 redirect. I save the friendly url string in the database and check if it's equal to the one provided, if not, I redirect to the one in the database. – Liron Harel Nov 24 '15 at 14:05
  • Absolutely, but performance should also be considered. It will be added to Render time that this issue has a negative effect on rankings – Ehsan Jun 13 '17 at 08:30
0

A short url with slug is seo-friendly according to What is a slug and how to optimize it?.

And, the example url with slug and id below is seo-friendly enough. *If the url doesn't have id, it's more seo-friendly because it's shorter but I know that id is really useful to look up an object so no problem:

                 # ↓ "slug" ↓
http://myshop.com/orange-juice/id
                         # "id" ↑
Super Kai - Kazuya Ito
  • 22,221
  • 10
  • 124
  • 129
0

Use something like modrewrite to parse URLs before they reach your server. So you could convert a slug like http://oorl.com/99942/My-Friendly-Text-For-Search-Engines/ into http://oorl.com/lookup.php?id=99942. This will also let you change slug and keywords used to optimize certain links without damaging functionality.

Patrick Gryciuk
  • 712
  • 4
  • 7
-1

Yes, and in fact it's more SEO friendly to include a number in your url as it implies to google that you are consistently updating your content.

I am fairly sure that it makes it much more difficult to get indexed in Google News if you don't have an incrementing number attached in some way to your URLs.

cam8001
  • 1,581
  • 1
  • 11
  • 22