为什么jekyll --server返回错误

时间:2013-05-01 16:27:29

标签: ruby jekyll rbenv

我注意到有几篇与此相似的帖子,但不明白如何解决这个问题。

我安装了ruby 1.9.3-p392的rbenv,当我运行jekyll时出现以下错误--server:

Configuration from /Users/seiju/Sites/a8os/_config.yml
Building site: /Users/seiju/Sites/a8os -> /Users/seiju/Sites/a8os/_site
Liquid Exception: undefined method `xmlschema' for nil:NilClass in sitemap.xml
/Users/seiju/.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/jekyll-0.12.1/lib/jekyll/filters.rb:57:in `date_to_xmlschema'
/Users/seiju/.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/liquid-2.5.0/lib/liquid/strainer.rb:43:in `invoke'
/Users/seiju/.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/liquid-2.5.0/lib/liquid/context.rb:75:in `invoke'
/Users/seiju/.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/liquid-2.5.0/lib/liquid/variable.rb:50:in `block in render'
/Users/seiju/.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/liquid-2.5.0/lib/liquid/variable.rb:38:in `each'
/Users/seiju/.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/liquid-2.5.0/lib/liquid/variable.rb:38:in `inject'
/Users/seiju/.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/liquid-2.5.0/lib/liquid/variable.rb:38:in `render'
/Users/seiju/.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/liquid-2.5.0/lib/liquid/block.rb:106:in `block in render_all'
/Users/seiju/.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/liquid-2.5.0/lib/liquid/block.rb:93:in `each'
/Users/seiju/.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/liquid-2.5.0/lib/liquid/block.rb:93:in `render_all'
/Users/seiju/.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/liquid-2.5.0/lib/liquid/block.rb:82:in `render'
/Users/seiju/.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/liquid-2.5.0/lib/liquid/template.rb:124:in `render'
/Users/seiju/.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/liquid-2.5.0/lib/liquid/template.rb:132:in `render!'
/Users/seiju/.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/jekyll-0.12.1/lib/jekyll/convertible.rb:79:in `do_layout'
/Users/seiju/.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/jekyll-0.12.1/lib/jekyll/page.rb:100:in `render'
/Users/seiju/.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/jekyll-0.12.1/lib/jekyll/site.rb:204:in `block in render'
/Users/seiju/.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/jekyll-0.12.1/lib/jekyll/site.rb:203:in `each'
/Users/seiju/.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/jekyll-0.12.1/lib/jekyll/site.rb:203:in `render'
/Users/seiju/.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/jekyll-0.12.1/lib/jekyll/site.rb:41:in `process'
/Users/seiju/.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/jekyll-0.12.1/bin/jekyll:264:in `<top (required)>'
/Users/seiju/.rbenv/versions/1.9.3-p392/bin/jekyll:23:in `load'
/Users/seiju/.rbenv/versions/1.9.3-p392/bin/jekyll:23:in `<main>'
Build Failed

我很困惑,不知道从哪里开始解决这个问题。我也在使用jekyll版本(0.12.1)。

以下是我的sitemap.xml:

---
---

<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="/sitemap.xsl"?>
<urlset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd" xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">    
<url>
<loc>http://aceeightofspades.com/</loc>
<lastmod>{{ site.time | date_to_xmlschema }}</lastmod>
<changefreq>daily</changefreq>
<priority>1.0</priority>
</url>
<url>
<loc>http://aceeightofspades.com{{ post.url }}/</loc>
<lastmod>{{ post.date | date_to_xmlschema }}</lastmod>
<changefreq>weekly</changefreq>
<priority>0.8</priority>
</url>
</urlset>

1 个答案:

答案 0 :(得分:3)

您似乎正在尝试为不存在的顶级<url>对象创建post条目。我认为你想要的是循环你的帖子并为每个帖子创建一个条目。

这样的事情:

{% for post in site.posts %}
<url>
  <loc>http://aceeightofspades.com{{ post.url }}/</loc>
  <lastmod>{{ post.date | date_to_xmlschema }}</lastmod>
  <changefreq>weekly</changefreq>
  <priority>0.8</priority>
</url>
{% endfor %}

这会将您的第二个<url>块与{% for post in site.posts %}{% endfor %}包裹起来,以便在该块post内不再为空。