31 December 2015

Getting live search working in Jekyll was a real accomplishment but the results displayed still need some improvement. For instance, dates are not showing up yet for posts.

At first, the search was completely not working. I was getting errors like this when entering a search term.

Uncaught TypeError: $(...).lunrSearch is not a function

After some testing, I discovered this problem was fixable by repositioning my loading of jQuery. I moved the loading of it from the end of the body to the end of the head in my template. I’m maintaining a local copy in /js and loading it with the following statement.

<script src="/js/jquery-1.11.3.min.js"></script>

Here is how to live search looks when searching for the term code. I noticed that I could not set the minimum length for search terms lower than three characters.

Live search in Jekyll is now working.

When I first installed the Ruby gem for jekyll-lunr-js-search, I received a number of errors. I narrowed all of the errors down to a single dependency, therubyracer.

$ gem install therubyracer
Fetching: therubyracer-0.12.2.gem (100%)
Building native extensions.  This could take a while...
Successfully installed therubyracer-0.12.2
Parsing documentation for therubyracer-0.12.2
unable to convert "xCF" from ASCII-8BIT to UTF-8 for ext/v8/accessor.o, skipping
unable to convert "xCF" from ASCII-8BIT to UTF-8 for ext/v8/array.o, skipping
unable to convert "xCF" from ASCII-8BIT to UTF-8 for ext/v8/backref.o, skipping
unable to convert "xCF" from ASCII-8BIT to UTF-8 for ext/v8/constants.o, skipping
unable to convert "xCF" from ASCII-8BIT to UTF-8 for ext/v8/constraints.o, skipping
unable to convert "xCF" from ASCII-8BIT to UTF-8 for ext/v8/context.o, skipping
unable to convert "xCF" from ASCII-8BIT to UTF-8 for ext/v8/date.o, skipping
unable to convert "xCF" from ASCII-8BIT to UTF-8 for ext/v8/exception.o, skipping
unable to convert "xCF" from ASCII-8BIT to UTF-8 for ext/v8/external.o, skipping
unable to convert "xCF" from ASCII-8BIT to UTF-8 for ext/v8/function.o, skipping
unable to convert "xCF" from ASCII-8BIT to UTF-8 for ext/v8/gc.o, skipping
unable to convert "xCF" from ASCII-8BIT to UTF-8 for ext/v8/handles.o, skipping
unable to convert "xCF" from ASCII-8BIT to UTF-8 for ext/v8/heap.o, skipping
unable to convert "xCF" from ASCII-8BIT to UTF-8 for ext/v8/init.bundle, skipping
unable to convert "xCF" from ASCII-8BIT to UTF-8 for ext/v8/init.o, skipping
unable to convert "xCF" from ASCII-8BIT to UTF-8 for ext/v8/invocation.o, skipping
unable to convert "xCF" from ASCII-8BIT to UTF-8 for ext/v8/locker.o, skipping
unable to convert "xCF" from ASCII-8BIT to UTF-8 for ext/v8/message.o, skipping
unable to convert "xCF" from ASCII-8BIT to UTF-8 for ext/v8/object.o, skipping
unable to convert "xCF" from ASCII-8BIT to UTF-8 for ext/v8/primitive.o, skipping
unable to convert "xCF" from ASCII-8BIT to UTF-8 for ext/v8/rr.o, skipping
unable to convert "xCF" from ASCII-8BIT to UTF-8 for ext/v8/script.o, skipping
unable to convert "xCF" from ASCII-8BIT to UTF-8 for ext/v8/signature.o, skipping
unable to convert "xCF" from ASCII-8BIT to UTF-8 for ext/v8/stack.o, skipping
unable to convert "xCF" from ASCII-8BIT to UTF-8 for ext/v8/string.o, skipping
unable to convert "xCF" from ASCII-8BIT to UTF-8 for ext/v8/template.o, skipping
unable to convert "xCF" from ASCII-8BIT to UTF-8 for ext/v8/trycatch.o, skipping
unable to convert "xCF" from ASCII-8BIT to UTF-8 for ext/v8/v8.o, skipping
unable to convert "xCF" from ASCII-8BIT to UTF-8 for ext/v8/value.o, skipping
unable to convert "xCF" from ASCII-8BIT to UTF-8 for lib/v8/init.bundle, skipping
Installing ri documentation for therubyracer-0.12.2
1 gem installed

Curing these conversion errors was accomplished by calling

$ gem install rdoc

I have the search running on the site at /search. I’ll probably add another post on how the search results can be improved once I solve those problems.



blog comments powered by Disqus