Copyright © 2011-2012
Matthew C. Smith

Jekyll Yaml Parse Error


Sample Blog Post

I have really enjoyed switching this site to Jekyll. It really works for me and I got up and running very quickly. The most frustrating part was when I made a change, then refreshed the browser and saw nothing change.

When running jekyll --server --auto this may occasionally happen to you as well. I was greeted with this message:

/home/matt/.rbenv/versions/1.9.3-p0/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require': iconv will be deprecated in the future, use String#encode instead.
Configuration from /home/matt/projects/nearapogee-jekyll/_config.yml
Building site: /home/matt/projects/nearapogee-jekyll -> /home/matt/projects/nearapogee-jekyll/_site
/home/matt/.rbenv/versions/1.9.3-p0/lib/ruby/1.9.1/psych.rb:154:in `parse': (<unknown>): couldn't parse YAML at line 14 column 0 (Psych::SyntaxError)
   from /home/matt/.rbenv/versions/1.9.3-p0/lib/ruby/1.9.1/psych.rb:154:in `parse_stream'
   from /home/matt/.rbenv/versions/1.9.3-p0/lib/ruby/1.9.1/psych.rb:125:in `parse'
   from /home/matt/.rbenv/versions/1.9.3-p0/lib/ruby/1.9.1/psych.rb:112:in `load'
   from /home/matt/.rbenv/versions/1.9.3-p0/lib/ruby/gems/1.9.1/gems/jekyll-0.11.2/lib/jekyll/convertible.rb:33:in `read_yaml'
   from /home/matt/.rbenv/versions/1.9.3-p0/lib/ruby/gems/1.9.1/gems/jekyll-0.11.2/lib/jekyll/post.rb:39:in `initialize'
   from /home/matt/.rbenv/versions/1.9.3-p0/lib/ruby/gems/1.9.1/gems/jekyll-0.11.2/lib/jekyll/site.rb:163:in `new'
   from /home/matt/.rbenv/versions/1.9.3-p0/lib/ruby/gems/1.9.1/gems/jekyll-0.11.2/lib/jekyll/site.rb:163:in `block in read_posts'
   from /home/matt/.rbenv/versions/1.9.3-p0/lib/ruby/gems/1.9.1/gems/jekyll-0.11.2/lib/jekyll/site.rb:161:in `each'
   from /home/matt/.rbenv/versions/1.9.3-p0/lib/ruby/gems/1.9.1/gems/jekyll-0.11.2/lib/jekyll/site.rb:161:in `read_posts'
   from /home/matt/.rbenv/versions/1.9.3-p0/lib/ruby/gems/1.9.1/gems/jekyll-0.11.2/lib/jekyll/site.rb:128:in `read_directories'
   from /home/matt/.rbenv/versions/1.9.3-p0/lib/ruby/gems/1.9.1/gems/jekyll-0.11.2/lib/jekyll/site.rb:98:in `read'
   from /home/matt/.rbenv/versions/1.9.3-p0/lib/ruby/gems/1.9.1/gems/jekyll-0.11.2/lib/jekyll/site.rb:38:in `process'
   from /home/matt/.rbenv/versions/1.9.3-p0/lib/ruby/gems/1.9.1/gems/jekyll-0.11.2/bin/jekyll:250:in `<top (required)>'
   from /home/matt/.rbenv/versions/1.9.3-p0/bin/jekyll:19:in `load'
   from /home/matt/.rbenv/versions/1.9.3-p0/bin/jekyll:19:in `<main>'

Obviously a parsing error, but I was just getting started with jekyll and I had be futzing (technical term) with a lot of settings, in many files.... Which one caused the error?

Clues to notice

It happened in line 14 and in column 0. This is helpful, but I skipped over that not knowing which file it was in.

The actual issue?

Well in this case, it was an un-indented line in one of the YAML headers, but it could have been any YAML issue.

teaser: |
This was the error...

Takaways

Now I refresh often after editing any YAML. If I notice some thing strange I rm -rf _site and run jekyll to generate the site again, which usually yields a better error than what you get when webrick is running. I also keep track of which files I edit more closely. (Thankfully vim keeps a nice ordered list.)

Also I notice that if you are running jekyll --server --auto it seems to take two refeshes to get edits to the browser (or stopping and restarting the server). I have not tracked down the 'why' to that one yet....

→ Written by Matt Smith on January 20, 2012 in Jekyll, Errors

blog comments powered by Disqus