Live data from Hacker News

Choosing between names and identifiers in URLs

cloudplatform.googleblog.com

1–10 of 157 posts

Re: Choosing between names and identifiers in URLs

#3
Great post - I quite like the stackoverflow.com style of `stackoverflow.com/questions//`, where can be changed to anything, and the link still works.

This allows for easy URL readability, while also having a unique ID.

In the context of this post (the library example) that would look like

library.com/books/1as03jf08e/Moby-Dick/

Re: Choosing between names and identifiers in URLs

#5
post #3

Great post - I quite like the stackoverflow.com style of `stackoverflow.com/questions/ / `, where can be changed to anything, and the link still works. This allows for easy URL readability, while also having a unique ID. In the context of this post (the library example) that would look like library.com/books/1as03jf08e/Moby-Dick/

Ha, I didn't realize that you could change the question title or even leave it out altogether without breaking the link. Neat!

Re: Choosing between names and identifiers in URLs

#6
For Canny, I wrote some awesome code that I'm proud of that turns a "post title" into a unique URL.

https://react-native.canny.io/feature-requests/p/headless-js...

For example, a post with title "post title" will get url "post-title".

Then a second post with title "post title" will get url "post-title-1".

Since there's only one URL part associated with each post, it's a unique identifier.

This gets rid of the ugly id in the URL, for epic URL awesomeness.

Furthermore, if you edit the first post to have "new post title" then its URL will update to "new-post-title", but "post-title" will still redirect to "new-post-title".

Someday I'm gonna open source a lib that lets you easily add awesome URLs to your app. :)

Re: Choosing between names and identifiers in URLs

#7
Why not make every URL that's shown in the title bar a permalink by default?

That way, you have the best of both worlds in all cases.

If another object tries to use the same URL as another object (which was used first), then a new URL must be generated (just add something at the end of the name).

Re: Choosing between names and identifiers in URLs

#9
post #3

Great post - I quite like the stackoverflow.com style of `stackoverflow.com/questions/ / `, where can be changed to anything, and the link still works. This allows for easy URL readability, while also having a unique ID. In the context of this post (the library example) that would look like library.com/books/1as03jf08e/Moby-Dick/

A bunch of news sites use similar URL parsing; they tend to not care about the "slug" either. I think this is, in the general case, the best way.

Re: Choosing between names and identifiers in URLs

#10
Nice, this reflects the choice I've made with a recent API design. This is especially important for entity names you don't control.

For example, we ingest gamertags and IDs from players of Xbox Live, PSN, Steam, Origin, Battle.net, etc. - each have their own requirements in terms of what is allowed in a username, and even whether or not they're unique. Often you can't ensure a user is unique by their gamertag alone. You can't even ensure uniqueness based on gamertag and platform name. Reality is that search is almost always required in these cases, and that's why we've implemented search in the way described in this article, with each result pointing to a GUID representing a gamer persona.

Post reply on HN