Skip to content

Instantly share code, notes, and snippets.

View madhur's full-sized avatar
🎯
Focusing

Madhur Ahuja madhur

🎯
Focusing
View GitHub Profile

This is the code I use for the tag cloud at www.librador.com:

{% for tag in site.tags %}
  {% assign t = tag.first %}
  {% assign posts = tag.last %}
  <a class="tag tag{{ posts | size }}" href="/tags/#tag-{{ t | to_id }}">{{ t }}</a>
{% endfor %}

It expects there to be a CSS class called tag and several ones called tag1, tag2, tag3 etc, where the number is the number of posts with that tag. Here's my version:

@@site_url = 'http://www.mysite.com'
task :cloud_basic do
puts 'Generating tag cloud...'
require 'rubygems'
require 'jekyll'
include Jekyll::Filters
options = Jekyll.configuration({})
site = Jekyll::Site.new(options)