jekyll with broken front matter, how to find the broken file?

与世无争的帅哥 提交于 2020-01-02 04:50:07

问题


When I make a syntax error in the front matter i'm getting the following error:

 /.../psych.rb:203:in `parse': (<unknown>): could not find expected
 ':' while scanning a simple key at line 6 column 1
 (Psych::SyntaxError)
        from /.../psych.rb:203:in `parse_stream'
        from /.../psych.rb:151:in `parse'
            from ....

Do you know a way to tell what file caused the problem?

I know that I could probably use DTrace as follows:

dtrace -n 'syscall::open*:entry { printf("%s %s",execname,copyinstr(arg0)); }'| grep _posts

But I'm looking for something more straight forward.


回答1:


it seams that jekyll does not work well on ruby 1.9.3. A more restrictive yaml parser was introduced: Psych that probably has different exception hierarchy and there for it is not properly handled by jekyll.




回答2:


You may find that this is caused by faulty formatting

If your front matter looks like this:

---
menu:
- text: Home
url: /en/index.html
- text: Overview
url: /en/overview.html
---

instead of

---
menu:
- text: Home
  url: /en/index.html
- text: Overview
  url: /en/overview.html
---

then the YAML parser will throw it out.



来源:https://stackoverflow.com/questions/10417122/jekyll-with-broken-front-matter-how-to-find-the-broken-file

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!