From Bitly to Yourls

Eleven years ago, I read a post about a technique to reference online material in hand-written notebooks. The idea was to use a URL shortener to write the “backhalf” of the URL in the notebook, with a delimiter (as well as a few formatting ideas for clarity). “Backhalf” refers to the shortened part of the link; “fronthalf” refers to the shortener. If a shortned url is https://shortener.com/12345, then shortener.com is the fronthalf, and 12345 is the backhalf. If I click on the link, it will go to some other site.

The author suggested using Bitly, as, at the time, you could create a custom fronthalf as part of their free service. I mapped it to l.mrguilt.com, and my notebooks have scattered references ever since. This scheme has worked out rather well.

I learned recently that Bitly paywalled a number of features, including the custom fronthalf. I’ve been grandfathered in, for a time, but, as these things go, I knew it was a matter of time before they would force a subscription.

But I’m a geek with servers in the Cloud. I could set up my own URL shortener, with my own custom front end.

Yourls

I looked at a few, and settled on Yourls. It had the most straight-forwward setup, though a bit quirky. After about an hour of tinkering, downloading components, and setting up a database, I was good to go. I had decided to retain Bitly as long as they’d let me, so the new frontend would be s.mrguilt.com. I decided to designate references to it as <<backend>>, where the Bitly version was <backend>.

So far, so good.

Exporting from Bitly

As I said, I suspected they would eventually end my grace period, and with it my custom frontend. I could use bit.ly/backend, and it would still work, so long as the overall service had a free tier. Also, at the end of the day, I viewed all of this as my data. I wanted to be able to put a copy on a device I controlled. Did Bitly have an export feature?

It did. But the export feature was also paywalled at a $30/month tier. Was there another way?

I could get a list of all the links in one list on the web site. ⌘-a even highlighted it all, so I was able to ⌘-c it into a text file. The formatting was goofy, but I had my data!

26-Nov-25
No tags

Favicon for sallysbakingaddiction.com
Soft Dinner Rolls Recipe - Sally's Baking
l.mrguilt.com/44oZ0fO




https://sallysbakingaddiction.com/soft-dinner-rolls/#tasty-recipes-67831
0 engagements

I then wrote a perl script to parse that into a comma separate values (CSV) file.

#!/usr/pkg/bin/perl
open(INFILE,"/~/bitly-dump.txt");


$foundit=0;
foreach $i (<INFILE>) {
    chomp($i);
    if($i=~ /.*l\.mrguilt\.com\/(.*)/) {
        print $1,",";
        $foundit=1;
    }
    if($foundit==1) {
        if($i=~ /(http.*)/) {
            print $i,"\n";
            $foundit=0;
        }
    }
}


close(INFILE);

Turned my copy-and-paste line into:

44oZ0fO,https://sallysbakingaddiction.com/soft-dinner-rolls/

I had my data!

Import into Yourls

I could have stopped there. However, Yourls had an import module. I tested it: I could import both the target URL as well as the backend. This meant that l.mrguilt.com/12345 and s.mrguilt.com/12345 would go to the same place. All my legacy references would continue to work as they had been. 88% of the Bitly URLs successfully imported. As of this writing, I have not spent a lot of time examining what didn’t work–it could be dead target URLs, for instance. Regardless, I have the spreadsheet to refer to.

I’ve decided to sunset my Bitly account after a month or so of running in parallel. I’ll probably go back to the older marker (<backhalf>) when I do. I’m quite pleased that I was able to not only create a replacement, but migrate my historical data into it.