Libravatar filter for Jekyll

My blog is powered by Jekyll and I display gravatars on comments and for post author. As stated in my previous post, it's a centralized service. Now there is libravatar doing the same but not centralized. I wrote a gravatar liquid filter, now here is the libravatar liquid filter:

require 'libravatar'

module Jekyll
  module LibravatarFilter
    def to_libravatar(input)
      Libravatar.new(:email => input)
    end

    def to_secure_libravatar(input)
      Libravatar.new(:email => input, :https => true)
    end
  end
end

Liquid::Template.register_filter(Jekyll::LibravatarFilter)

It's based on libratar ruby gem that you have to install first:

$ gem install libravatar
  • With this input: {{ 'user@example.com' | to_libravatar }}
  • The filter will output something like:
    http://avatars.example.com/avatar/8ab058066d75ea5b7e613094a7676d82

See the libravatar filter on github.

Comments Add one by sending me an email.