Rolling Your Own Link Shortener With the .IM Domain and Automating it With WordPress Jetpack

Link shorteners were very in vogue in the early 2010s but they seem to have fallen out of favor somewhat since most social networks now automatically shorten links (and don’t count links against your character count) and popular networks like Instagram don’t really even allow links at all. Bitly was the elephant in the room for link shortening and they do offer a white-label service. But it’s expensive. A link shortener is a ‘nice to have’ for a business but frankly, it’s not worth paying $29 a month.

As always, I was keen to find my own solution, to fit my own specific needs, and pay as little as possible for it.

At the most fundamental level, a link shortener takes a long link, and shortens it and redirects it to the long link when it’s clicked. It’s basically a fancy .htaccess redirect script.

Jealous of my boss’s very, very short link shortener (mj.ie). I set out to have my own for my business brand, Anglotopia.

I tried lots and lots of combinations. I wanted the shortest version possible that had at least the word ‘anglo’ in it. The problem was that since it’s a common word, there wasn’t a lot of TLD’s still available using anglo. Eventually, I settled on Anglo.top. It seemed ideal as it had most of my company name in it and it was still relatively short. I registered it and then set up a link shortener. I was informed shortly after that .TOP is actually not a very good domain to use for something like this – because it’s has a heavy association with SPAMMERS – so if you use the links in email or social media, it is more likely to get blocked or filtered out.

So, back to the drawing board.

After some digging, I found that anglo.im was available directly from the Isle of Man Domain Registry (but strangely not through my register of choice these days – Blacknight). It was a bit pricey – £40 a year – but that was still cheap enough to be useful for this project. I could also use it for other things. Short domains are great! And versatile – I may even use it for email one day. I was able to secure ‘anglo.im.’

So, how do you go about setting up a link shortener?

First, you need a server. Any Linux server will do. I happen to have my own dedicated server with Blacknight, so I can put whatever I want on it. I used Softaculous to install YOURLS in seconds, which is an open-source PHP URL shortener. While the tool is pretty basic, with a very dated interface, it works really, really well. It makes the links and tracks the links so you can get stats on how many times something was clicked.

You can set up bookmarklets and Google Chrome extensions to make short links without even having to log in to the service because it has a handy little API.

I’m a fan of automation. With a full-time job and a side-business that takes a lot of spare time, I really didn’t want to have another thing to do – that being creating short links every time I publish or share something. Thankfully, YOURLS integrates easily with WordPress. If you install the BetterYOURLS plugin, you can then automatically create a short link when you publish a post (and customize it if you wish).

When I publish an article on Anglotopia or Londontopia, it’s automatically shared to Twitter and Facebook, so I wanted the links that were shared there to also be the short link. This proved a bit trickier. But I found a workaround.

How to use YOURLS with Jetpack URL Shortener

  1. Download and install Jetpack
  2. Enable the Jetpack URL shortener under the sharing settings.
  3. Install BetterYOURLS, activate and setup with your API key
  4. Then, this is the key part, now go to Jetpack and then deactivate the Jetpack URL shortener
  5. Then, when you publish an article it’ll use your own custom short URL on Twitter and Facebook. If you don’t do this, it won’t work. It took me a few hours to work this out…

Initially, I ran into issues that when these posts were published to Facebook or Twitter, it was not pulling the right Open Graph image, or none at all and when you tried to ‘refresh share attachment’ on Facebook, it still wouldn’t work. I never found a solution to this problem, but a while ago the problem seemed to fix itself.

So, for minimal investment – just £40 (about $50), I was able to set up my own branded URL shortener for all my links that I publish and when people share links from Anglotopia, it uses the short links as well. There’s really no reason to do this, other than to have another way to be branded on the internet. But as we know, links are the currency of the internet and if they’re something you can control, you absolutely should.

I also recently registered jwt.im, which are my initials, to have the shortest possible URL for when I share links personally or on this personal blog. It’s not 4 letters, but five is close enough! I also found this really short domain useful for setting up a 1 letter email address for registering for things quickly or logging into accounts on smart tv’s – a painful process when you have to type in a long email address.