Article

Playing nice: numeric vs. natural resource ids

John Susser expands on the discussion revolving around DHH’s RailsConf keynote on ActiveResource, saying that natural URLs (i.e. /employees/josh) and numeric URLS (i.e. employees/13) needn’t be mutually exclusive. You could do something like employees/13/josh, which ir programatically more correct and also human/search-engine readable.

I just wanted to point out that Feedmarker has been doing this for some time, and I’m convinced it has helped in terms of search-engine visibility. For example, here’s the permanent link to a recent bookmark of mine:

http://www.feedmarker.com/id/39121/The+First+Church+of+Jesus+Christ%2C+Elvis

The number following /id/ is the unique id of the bookmark, and anything following is strictly decoration; the page will load just the same without it. But it gives humans (and spiders) reading the URL a better idea of what they’re going to find. I think

Comments (3 comments)

I agree with your point, but would like to add: unless the numeric is ridiculously large. In you example, for instance, if it was:
employees/1238191231234242323423412/josh

or some form of GUID, the user may not even scan to the end of the URL. Thoughts?

Larry Roth / July 19th, 2006, 8:59 pm / #

Good point, but in Rails it’s not hard to configure that round the other way around, so that the human readable stuff (which a computer would ignore) comes first, followed by a number, which can be as long as you want.

The other problem (which I think Josh mentions) is that with this method you could have many, many different URLs that all point to the same resource. That’s not exactly the spirit of the web, but there’s probably a way around it (by sending the appropriate response headers for URLs that aren’t The Correct URL).

bruno / July 19th, 2006, 10:38 pm / #

Hello! Good Site! Thanks you! unmmxqxbzrx

kupbshlqka / June 14th, 2007, 1:32 pm / #

Post a comment