1

First question here and new to Ruby and Jekyll so forgive me if I miss some important details.

I'm trying to use bundle exec jekyll serve to generate my static site, but I keep getting the following error message:

  Liquid Exception: undefined method `fetch' for true:TrueClass in sitemap.xml

Edit: The problem was I had deleted/modified the something in my collections configuration in my _config.yml.

It should have been

collections:
  my_collection:
    output: true

...but instead was simply

collections:
      output: true

Not sure if it was always like that, or if I had modified it somehow. Check your _config.yml!

Christian
  • 4,902
  • 4
  • 24
  • 42
  • Welcome to Stackoverflow! Do you have some code or logs to share? Have you tried `bundle exec jekyll serve --trace`? I have read the docs on https://github.com/jekyll/jekyll-sitemap and haven't found any hint. – Christian Jan 04 '20 at 01:29
  • Hi Christian! Thanks for your reply. Editing my post with the results of `bundle exec jekyll serve --trace` – Caleb Miller Jan 04 '20 at 14:59
  • The error comes from [this line of the source code](https://github.com/jekyll/jekyll/blob/654d3810395f2247a699b3aa3f828bc6d1ef30f6/lib/jekyll/collection.rb#L187). I guess it is somehow related to your collection configuration or collection metadata in your config.yml file. A similar issue was [reported and fixed by changing the config here](https://github.com/mmistakes/minimal-mistakes/issues/1799) and I suggest to read more about [Jekyll collections](https://jekyllrb.com/docs/collections/). – Christian Jan 04 '20 at 23:21

1 Answers1

0

I have tested the gem without getting any error.

_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

book.md in my_collections\books

---
title: first book
---

first book

Resulting 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>

As said in my comment above I assume that there is a problem in your collection configuration in your _config.yml file. Also, there are some known issues listed on the official plugin page.

Christian
  • 4,902
  • 4
  • 24
  • 42
  • 1
    This is it!!! I had somehow deleted a vital line in my collection configuration. Just replaced it and everything is running smoothly. Thank you so much. – Caleb Miller Jan 04 '20 at 23:59