Live data from Hacker News

Examples of Great URL Design (2023)

blog.jim-nielsen.com

61–70 of 163 posts

Re: Examples of Great URL Design (2023)

#61
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.

At least that stuff is actually informative to a human. A lot of Amazon's URL bloat is the analytics crap they shove into query string. I started using ClearURLs specifically because of Amazon.

Re: Examples of Great URL Design (2023)

#62

We take the typical blog url design (/2024/08/14/slug) for granted but back in the very early 2000s pretty much every blog tool had its own URL design. Matthew Thomas back then took an inventory: https://web.archive.org/web/20030810201315/http://mpt.phrase... He was on the search for his ultimate blogging system, where this "cruft-free" URL structure should be used: https://web.archive.org/web/20051107103030/http://m…

He calls file extensions cruft, but i've come to value them. They are a simple way to indicate file type - desired or offered - which is easily understood by machines and people.

I currently work with an API which does a bit of content negotiation using the Accept header, so clients can request data in various formats - application/json for a snapshot, text/event-stream for an updating feed, or text/html for an interactive dashboard. I wish it didn't. I wish we'd just used file extensions. Trivial to use in a browser or via curl, trivial to implement on either side.

Re: Examples of Great URL Design (2023)

#63
post #60
post #32

I forget where I ran across it, but one interesting adoption of URL design is to make the root of the directory part of the site's domain name. I.e. there was someone's website that was shared on HN, where their name was assembled with the domain name, TLD, and some characters after the first slash: firstna.me/lastname/ firstna.me/lastname/about

This arguably started with del.icio.us.

And I'm so glad they eventually registered delicious.com (or whatever it was) because remembering exactly where those "."s went was a real pain.

Re: Examples of Great URL Design (2023)

#64
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.

Changing the title of the question is the real wtf.

Re: Examples of Great URL Design (2023)

#65
post #37
post #10

One big question in URL design is this: Do path parameters get to have / in their values? Let’s say you have a link shortener service and want to allow users to define shortcuts like /mypath/:rest where rest is appended to example.com/ Now you’re in a very interesting position when it comes to resolving URLs. Curious to hear folks with experience in this

This can be a complex topic if you don’t set clear constraints on what constitutes a valid character in your URL or domain. For instance, in query parameters, spaces are encoded as '+'. But what if '+' is also a valid character in your domain? You then need to disambiguate i.e between "name?foo+bar" meaning "foo bar" or "foo+bar". Which one is the user actually referring to? In our case, we ended up needing users to…

Wouldn't you just encode the "+" if you wanted it as a literal?

Re: Examples of Great URL Design (2023)

#67
post #32

I forget where I ran across it, but one interesting adoption of URL design is to make the root of the directory part of the site's domain name. I.e. there was someone's website that was shared on HN, where their name was assembled with the domain name, TLD, and some characters after the first slash: firstna.me/lastname/ firstna.me/lastname/about

For another example, the recently featured https://fastht.ml/

Re: Examples of Great URL Design (2023)

#69

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/

"Q: Can I provide my own wood? A: In most cases we can handle your wood. We do require all shipments to be clean, free of parasites and pass all standard customs inspections."

Re: Examples of Great URL Design (2023)

#70
post #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 charact…

On the other hand, slugs may save you a long page load. Which is useful for users with slow internet.
Post reply on HN