这里的第一个问题,如果我错过一些重要的细节,请原谅。
我正在尝试使用bundle exec jekyll serve
生成我的静态站点,但是我不断收到以下错误消息:
Liquid Exception: undefined method `fetch' for true:TrueClass in sitemap.xml
我已禁用所有插件,然后逐个重新启用它们,这很明显是由jekyll-sitemap
插件引起的(在错误消息中也很明显)。
我尝试通过简单地禁用它来解决它,因为我认为这个小博客项目不需要它(如果我错了,请纠正我),但是如果我禁用它,则我的{% for %}
都不会循环在Liquid中,似乎不再起作用,因为仅生成了我的index.html
。我看不到为什么将它连接到jekyll-sitemap
,但是我对Ruby和Jekyll还是陌生的。
感谢您的时间,让我知道是否有什么需要澄清的!
编辑:问题是我在_config.yml的集合配置中删除/修改了某些内容。
应该是
collections:
my_collection:
output: true
...但是只是简单地
collections:
output: true
[不确定是否总是那样,还是我以某种方式对其进行了修改。检查您的_config.yml!
我已经测试了宝石,没有出现任何错误。
_ config.yml
plugins:
- jekyll-sitemap
collections_dir: my_collections
collections:
books:
output: true
Gemfile
source 'https://rubygems.org' do
gem "jekyll"
gem 'jekyll-sitemap'
end
my_collections \ books中的book.md
---
title: first book
---
first book
结果sitemap.xml
<?xml version="1.0" encoding="UTF-8"?>
<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://localhost:4000/books/book/</loc>
</url>
<url>
<loc>http://localhost:4000/</loc>
</url>
</urlset>
正如我在上面的评论中所说,我认为_config.yml文件中的集合配置中存在问题。另外,official plugin page上列出了一些已知的问题。