Live data from Hacker News

Examples of Great URL Design (2023)

blog.jim-nielsen.com

31–40 of 163 posts

Re: Examples of Great URL Design (2023)

#31
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 think this is actually a really great design in that the name of the product can always be in the URL. The "slug" is completely ignored and just there for SEO/humans. If you send a link I instantly know what it's for -- that's pretty useful!

I also like that the "id" which is an ASIN (Amazon Standard Identification Number) which is a superset of all ISBNs. This means you can just enter any book ISBN directly into the browser and end up on the right page (at least historically) instead of having to search for it.

Re: Examples of Great URL Design (2023)

#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

Re: Examples of Great URL Design (2023)

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

that's what the many-to-one slug-to-id mapping is for

Re: Examples of Great URL Design (2023)

#34
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 think this is actually a really great design in that the name of the product can always be in the URL. The "slug" is completely ignored and just there for SEO/humans. If you send a link I instantly know what it's for -- that's pretty useful! I also like that the "id" which is an ASIN (Amazon Standard Identification Number) which is a superset of all ISBNs. This means you can just enter any book ISBN directly into t…

This got a major retailor (Walmart maybe?) into issues awhile back as they were pulling the product title (only) from this param so people were having a heyday "renaming" official products on the official site.

Re: Examples of Great URL Design (2023)

#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 send the name in the body, and now we have to manage multiple encoding protocols (url, queryparam, the body...).

Re: Examples of Great URL Design (2023)

#39

I don't think will be relevant going forward, Safari already hides the URL beyond the domain name by default, and I presume other browsers do/will too.

As the article mentions, URLs are used in more contexts than being displayed in the address bar, so the content remains relevant regardless of Safari's poor aesthetic decisions.

Re: Examples of Great URL Design (2023)

#40
post #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 noti…

I believe amazon does something similar for product pages. The `/dp/` is the product id that really matters.
Post reply on HN