1

我注意到一些与此类似的帖子,但不明白如何解决这个问题。

我安装了 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>
4

1 回答 1

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 %}

这用and包裹了您的第二个<url>块,因此该块内不再为空。{% for post in site.posts %}{% endfor %}post

于 2013-05-01T16:59:57.250 回答