Skip to content

saiqulhaq/jekyll_bitly_next

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

10 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Jekyll Bitly Next

Tests

A modern, maintained Jekyll plugin that provides Bitly URL shortening filters for your Jekyll sites.

πŸ”— About

This gem is a maintained fork of jekyll-bitly, which is no longer actively maintained. It provides seamless integration with Bitly's API to automatically shorten URLs in your Jekyll pages and posts.

✨ Features

  • πŸš€ Simple Liquid filter for URL shortening
  • πŸ” Secure token management via config or environment variables
  • πŸ’Ύ Automatic caching of shortened URLs
  • 🎯 Zero configuration required after token setup
  • πŸ§ͺ Fully tested and maintained

πŸ“¦ Installation

Using Bundler (Recommended)

Add this line to your Gemfile:

gem 'jekyll_bitly_next'

Then execute:

bundle install

Manual Installation

gem install jekyll_bitly_next

Configure Jekyll

Add the plugin to your _config.yml:

plugins:
  - jekyll_bitly_next

Note: Older Jekyll versions used gems: instead of plugins:. If you're using an older version, use:

gems:
  - jekyll_bitly_next

πŸ”‘ Configuration

Step 1: Get Your Bitly API Token

  1. Log in to your Bitly account
  2. Navigate to https://app.bitly.com/settings/api/
  3. Generate a new API token
  4. Copy the token for use in the next step

Step 2: Configure the Token

You can configure your Bitly token using either of these methods:

Option 1: Jekyll Config (Recommended for local development)

Add to your _config.yml:

bitly:
  token: YOUR_BITLY_API_TOKEN_HERE

⚠️ Security Warning: Never commit your API token to public repositories. Add _config.yml to .gitignore or use environment variables for production.

Option 2: Environment Variable (Recommended for production)

Set the BITLY_TOKEN environment variable:

# Linux/macOS
export BITLY_TOKEN=YOUR_BITLY_API_TOKEN_HERE

# Windows (Command Prompt)
set BITLY_TOKEN=YOUR_BITLY_API_TOKEN_HERE

# Windows (PowerShell)
$env:BITLY_TOKEN="YOUR_BITLY_API_TOKEN_HERE"

For permanent setup, add it to your .bashrc, .zshrc, or system environment variables.

Priority: Config file settings take precedence over environment variables.

πŸš€ Usage

Basic Usage

Use the bitly filter in your Jekyll templates, pages, or posts:

[Visit the Bitly gem]({{ 'https://github.com/philnash/bitly' | bitly }})

Advanced Examples

In blog posts:

---
layout: post
title: "My Awesome Post"
canonical_url: https://yourdomain.com/2025/10/awesome-post
---

Share this post: {{ page.canonical_url | bitly }}

In layouts:

<a href="{{ page.url | absolute_url | bitly }}" class="share-link">
  Share on Twitter
</a>

With site variables:

{% assign short_url = site.url | append: page.url | bitly %}
<meta property="og:url" content="{{ short_url }}" />

πŸ› οΈ Development

Prerequisites

  • Ruby 2.7 or higher
  • Bundler

Setup

  1. Clone the repository:
git clone https://github.com/saiqulhaq/jekyll_bitly_next.git
cd jekyll_bitly_next
  1. Install dependencies:
bin/setup
# or
bundle install
  1. Run the tests:
bundle exec rspec
  1. Run an interactive console:
bin/console

Making Changes

  1. Create a feature branch: git checkout -b my-feature
  2. Make your changes
  3. Add tests for your changes
  4. Run tests: bundle exec rspec
  5. Commit your changes: git commit -am 'Add new feature'
  6. Push to the branch: git push origin my-feature
  7. Create a Pull Request

🀝 Contributing

We welcome contributions! Here's how you can help:

  1. Report bugs: Open an issue on GitHub
  2. Suggest features: Open an issue with your ideas
  3. Submit pull requests: Fork, create a feature branch, and submit a PR
  4. Improve documentation: Help us make the docs better

Please note that this project is released with a Contributor Code of Conduct. By participating in this project, you agree to abide by its terms.

πŸ“ Changelog

See CHANGELOG.md for a list of changes in each version.

πŸ“„ License

This gem is available as open source under the terms of the MIT License.

πŸ™ Credits

About

Jekyll filter that uses Bit.ly to shorten URLs

Resources

License

Code of conduct

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •