Live data from Hacker News

Examples of Great URL Design (2023)

blog.jim-nielsen.com

21–30 of 163 posts

Re: Examples of Great URL Design (2023)

#21
post #2

An example of a not-so-great URL design: Amazon product links have an optional slug before everything else like `{slug}/dp/{id}`. So you end up copying a gigantic URL everytime you wish to share a product unless you use the share product button to get the shortened link.

I just delete everything after the product ID manually. There are probably easier methods.

The point is that the id comes last.

Re: Examples of Great URL Design (2023)

#22
post #5

Earlier quoted context omitted.

The first example is just that. Put the id in the URL and make the slug optional. Stackoverflow makes the slug completely optional but you have the choice of only accepting foo and bar in your example

> https://stackoverflow.com/questions/78870603/i-LOVE-genocide This is bad.

It’s not great but it matters less when the content you get going to that page is so unremarkable. Don’t forget you can do that to any url, even of sites that don’t use optional slugs, if your goal is just vague, evil-by-link-appearance.

Re: Examples of Great URL Design (2023)

#23
Similar to the Slack example given in the post with /is/ URLs, KDE has /for/ URLs with pages which present the KDE project and software for various user profiles: developers, kids, scientists, students, creators, gamers, activists, etc.

See all these pages here: https://kde.org/for/

Re: Examples of Great URL Design (2023)

#24
post #13

Using a numeric ID + ignored path part is easy to implement, but actually using the textual part without an exposed ID seems more elegant to me. Tip for implementing that: * have a separate table that maps slugs to IDs, allowing many-to-one relationship, because content's title will be updated, and you don't want to break old links. * long slugs will get truncated by users. A zero-cost way to recover from that is `se…

[deleted]

Re: Examples of Great URL Design (2023)

#25

Shout out to the classic "Cool URIs don't change": https://www.w3.org/Provider/Style/URI

... and the classic Penisland: https://www.penisland.net/

I still chuckle at the expertsexchange.com -> experts-exchange.com migration.

Re: Examples of Great URL Design (2023)

#26
id's that skip the textual part on their lookup/url validation and also don't redirect are not ideal, probably as bad as soft 404s. Maybe not as bad for bots if the canonical tag shows the intended URL.

Personally I'd avoid using id's and use a 32-bit hash of the URL which is more or less as performant as a straight id lookup. I usually went with murmurhash.

Re: Examples of Great URL Design (2023)

#28
post #13

Using a numeric ID + ignored path part is easy to implement, but actually using the textual part without an exposed ID seems more elegant to me. Tip for implementing that: * have a separate table that maps slugs to IDs, allowing many-to-one relationship, because content's title will be updated, and you don't want to break old links. * long slugs will get truncated by users. A zero-cost way to recover from that is `se…

the problem with that, as mentioned in the article, is that that breaks if the content of the page changes. So on stack overflow for example, what happens if someone changes the title of their question? you either break the url or use an old version of the title, thus being misleading.

Re: Examples of Great URL Design (2023)

#29
I found Notion's URL schema interesting as well. They have to contend with renames of pages, reorganisation of the hierarchy and all that. So they have something like:

    notion.so/:account/Current-Name-of-Page-:pageid 
where the name changes if the page is renamed, but the redirect works, as the page ID is unchanged. In fact, one can just use

    notion.so/:account/:pageid 
and gets redirected to the right page, or even

    notion.so/:account/Anything-else-:pageid
works too...

This is very handy in my use cases, when various Notion data is extracted into another tool, reassembled, and then needed to have a link to the original page. I don't need to worry about the page's name, or how that name gets converted into the URL, or any race conditions....

The page hierarchy is then just within the navigaton, not in the URL, so moved pages continue to work too (even if this looks like a flatter hierarchy than it really is).

I'm sure there are plenty of drawbacks, but I've found it an interesting, pragmatic solution.

Re: Examples of Great URL Design (2023)

#30
I might be an outlier, but I don't like slugs in URLs.

They make URLs unnecessarily long, often forcing people to use URL shorteners -- completely defeating the purpose.

They get awkward when the author changes the title. Other commenters mentioned some tricks to get around this issue, but all involve redirects. Cools URLs shouldn't change in the first place.

They don't copy cleanly if you use nonalphanumeric characters, as in nearly every language other than English.

Virtually nobody just looks at a URL these days anyway, with all the search engines, cute thumbnails, and OpenGraph metadata that provide a glimpse of the actual content for you before you even click on it. This is doubly true in the non-English-speaking parts of the world where a slug in a shared URL is often just a jumble of %HEX.

Hand-picked words in URLs are fine, e.g. /about/me. I'm only talking about autogenerated slugs for user-submitted content above.

Post reply on HN