Jekyll: Generate Links on The Fly with Liquid

We needed a quick way of generating shortened links in our articles. Since we already use 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 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 gem:

$ sudo gem install bitly

Once you have installed the gem simply put the below file in your _plugins folder.

Update your configuration file with the following values:

  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 API.

, ,