Skip to main content

Easily showcase your Google Scholar metrics in Jekyll

Whether you’re applying for academic positions, comparing yourself to your colleagues, or determining whether people on Twitter really deserve their grant funding, it’s important to look at scholarly metrics such as h-index, i10-index, and number of citations. However, showing them off directly in your CV is a major bummer, especially when you’re an academic superstar and are too busy to update these vital statistics for all the conferences, grants, and positions you’re applying for! In this blog post, I’ll tell you three easy steps to automatically fetch these stats from Google Scholar and display them on your online vita with Jekyll.

First, take the below code, save it as a new file, scholar_stats.rb, and place it in your _plugins folder.1

require 'open-uri'
require 'nokogiri'

module Jekyll
  class ScholarStats < Generator
    # Replace `SCHOLAR_ID` with your own Google Scholar ID
    SCHOLAR_URL = ''.freeze
    def generate(site)
      doc = Nokogiri::HTML(URI.parse(SCHOLAR_URL + SCHOLAR_ID).open)
      tbl = doc.css('table').first
      tbl_data = { 'id' => SCHOLAR_ID }
      tbl.css('tr')[1..].each do |tr|
        cell_data = tr.css('td').map(&:text)
        tbl_data[cell_data[0].downcase.sub('-', '_')] = cell_data[1].to_i
      end['scholar'] = tbl_data

Second, update the SCHOLAR_ID constant with your Google Scholar ID. This is taken from the link for your Google Scholar profile, like, and it’s the characters after the user= part. The SCHOLAR_ID for this Scholar profile would therefore be z5el-twAAAAJ.

Finally, you might need to add these to your Gemfile and run bundle install:

gem "nokogiri"
gem "open-uri"

Or install them yourself with gem install open-uri nokogiri.

Once you’ve done this, you should have access to a few new variables in your Jekyll installation. You can use them in the Markdown or HTML documents using Liquid templates like so:

* [Profile]({{ }})
* Citations: {{ }}
* h-index: {{ }}
* i10-index: {{ }}

This Markdown code on my Jekyll site translates to:

Now sit back, relax, and watch as your numbers go up!

  1. If you are using something like GitHub Pages to publish your site, you might not be able to use custom plugins! Instead, generate your Jekyll site locally and then push the generated static files up to your git repository.

If you found this post useful, please consider supporting my work with a short stack 🥞.