I recently switched my NetBSD install from 32-bit to 64-bit and as a result had to re-build or re-install all the software I use. That included Jekyll. I intentionally re-installed an older version (1.5.1) because version 2 introduced a requirement for NodeJS and I've nothing against NodeJS, but I don't want to have to install it if I don't really need it.

However, I then immediately began getting Liquid Exception: invalid byte sequence in UTF-8 in ... errors. Absolutely nothing else had changed as far as I could tell so I knew it wasn't a problem with my files. I thought it might be because of using more recent gem dependencies of Jekyll than I had been using (as I never bothered to update them very often) under my 32-bit install and therefore a bit of a mismatch between them and the older version of Jekyll. So I upgraded Jekyll to 2.5.3 and actually found that although coffeescript, and thus NodeJS, is still a requirement, in preparation for version 3, where the requirement will be dropped, it is now remarkably easy to remove this requirement by editing ~/.gem/ruby/2.0.0/gems/jekyll-2.5.3/lib/jekyll.rb (or the site gem library if installed there) and right at the end of the file delete the coffeescript line:

# Eventually remove these for 3.0 as non-core
Jekyll::Deprecator.gracefully_require(%w[
  toml
  jekyll-paginate
  jekyll-gist
  jekyll-coffeescript
  jekyll-sass-converter
])

Unfortunately, although I could now run the latest Jekyll, I still had the same "byte sequence" error.

After much Duck-Duck-Going I found the blog post linked to in the title of this post. It, in turn, mentioned and linked to another post that claimed RDiscount was not very good with UTF-8 characters in URLs. I didn't think I had any (UTF-8 characters in URLs), but I thought, "What the hell, nothing to lose" and removed the requirement for RDiscount from my _config.yml; at some point over the years in my use of Jekyll I'd explicitly set RDiscount as my markdown parser because, as far as I can recall, of problems with the default Jekyll parser at the time. And, remarkably, that did the trick!

Since I was using RDiscount fine with Jekyll 1.5.1 under my 32-bit install it must just be either something related to a new "improved" version of RDiscount or some incompatibilities between that and recent versions of gem dependencies of Jekyll.

Anyway, there you go, if you are suddenly and inexplicably getting Liquid Exception: invalid byte sequence in UTF-8 in ... errors after years of everything being ok in Jekyll then check to see if you are still using RDiscount.