Sylvain UTARD

#geek #passionate #entrepreneur #french #epita #c++ #java #ruby #rails #js #textmining #searchengine #lucene #bigdata #nosql

I'm currently VP of engineering at Algolia.

How I improved Tom Preston-Werner's jekyll-based blog with 50 lines of code

I recently switched to Jekyll and was wondering how I could easily jump to old posts without displaying the famous “Last posts” menu.

What I need:

What I don’t want to do:

1. Menu-based

List last posts in ALL your pages, the old and ugly way.

<ul class="last_posts">  
  {% for post in site.posts limit:20 %}
       <span>{{ | date_to_string }}</span> &raquo;
       <a href="{{ BASE_PATH }}{{ post.url }}">{{ post.title }}</a>  
  {% endfor %}  

2. Search-based

You may have heard about lunr and its jekyll integration, you can find a demo here. It’s pretty awesome but it lacks critical features for now (most critical: stemming doesn’t replace typo-tolerance, matching terms are not highlighted issue 25).

It’s been 3 months since I’ve joined Algolia and I cannot let a day go by without trying to plug our search-engine somewhere new. Wow, my personal blog is totally “somewhere” new. Let’s give it a try; Algolia is NOT a site-search engine; but it could be the perfect match to easily jump on old posts.

WAIT! You said you don’t want to pay anything; Algolia is a paying service. You’re right, just send me an email and I’ll convert your 14-day free trial to an unlimited custom free plan.

First, I need to patch my dependencies (I use a Gemfile and you should too :p):

Let’s make it the proper way and add all configuration stuff in my _config.yml.

Reindex all post titles while publishing to Github’s gh-pages branch.

I used a patched version of Typeahead.js to be able to use it with an Algolia backend (see the pull-request).

Live demo with Tom Preston-Werner’s blog, CEO of Github and creator of Jekyll. You can find the whole patch on Github.