Jekyll: Generate Bit.ly Links on The Fly with Liquid
We needed a quick way of generating shortened links in our articles. Since we already use bit.ly we figured that would be the best choice and there are several Ruby scripts and gems available. We picked one that is actively developed, appears stable, as well as has support for bit.ly API V3.
bitly is the easiest and most fun way to save, share and discover links from around the web. We call these links bitmarks, and you can use bitly to remember, curate and share them.
First you have to install the Bit.ly gem:
$ sudo gem install bitly
Once you have installed the gem simply put the below file in your
Update your configuration file with the following values:
bitly: username: YOUR_BITLY_USERNAME api_key: YOUR_BITLY_KEY
Then you can use tags like this in your content:
Which would produce output similar to this:
The filter uses a cache to cache the shortened URLs during build time to minimize the calls to the Bit.ly API.