by adesanmi · 4y ago · 0 comments
A simple, generic way could be a hash of the original URL with a compact representation:
http://example.com/some/path/to/stuff?filter1=asdf&filter2=90#positionX
http://example.com/s/Wq_2
/s stands for "short" and the ID is the hash representation. If you use a-zA-Z0-9 plus some URL safe characters like _ it should be reasonably short even for large sites. The CMS or whatever software doesn't have to to implement something, because it is mostly just a generic URL shortener running on the same host. <link rel=short href="https://youtu.be/abcdef"/>
Then copying the URL could copy the short link instead.That being said I like when the URL is readable. The YouTube example works because everyone knows that YouTube is a video. Presumably for non-video links they could use something like /user/foobar to differentiate from their "main product". But for blog posts I would much rather see something like /short-urls rather than /su as the reader gets nothing from the first one.
<meta property="shortlink" content="https://bit.ly/shortlink">
Just because it's not a standard doesn't mean you can't use it. This is sort of futureproofing incase it does become a standard.It looks what I described is very existing to the spec published here: https://microformats.org/wiki/rel-shortlink