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!

3
  • 4
    Your question assumes that SEO is measurably beneficial, which it is not.
    – moo
    Sep 18, 2009 at 1: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.
    – user823082
    Jun 30, 2011 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! Jun 8, 2017 at 15:30

12 Answers 12

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" />

6
  • 1
    this is great advice! This really answers the question I was asking in a question here today. Thanks!
    – Evik James
    Sep 1, 2011 at 20:58
  • Wouldn't it be ok to just stop after the ID in the canonical URI?
    – DanMan
    Jun 26, 2014 at 22:49
  • @DanMan stopping after the ID would lose the benefits of having keywords in the indexable URL. Jun 29, 2015 at 10:44
  • 1
    "Black hats can this to cause duplicate content penalty for long tail competitors (trust me)." Do you have any sources on this? Aug 14, 2019 at 15:11
  • 2
    @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, 2019 at 8:24
72

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

I'd say you're fine.

3
  • 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, 2009 at 1: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, 2013 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, 2015 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.

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.

4
  • 1
    And how do you comment that all URLs submitted to Google News have to contain a numeric ID?
    – viam0Zah
    May 4, 2009 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 4, 2009 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. Aug 6, 2010 at 7:24
  • But if you dump the ID segment, you run the risk of having URLs like: stackoverflow.com/questions/820493/… and -2 and -3 and so on, which doesn't look professional. May 31, 2013 at 8: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

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.

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.

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.

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.

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.

2
  • 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. Nov 24, 2015 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, 2017 at 8: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" ↑
-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.

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

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.