algolia / algoliasearch-jekyll

⚠ DEPRECATED Use jekyll-algolia instead.
https://community.algolia.com/jekyll-algolia/
MIT License
125 stars 12 forks source link

`block in weight': undefined method `split' for nil:NilClass #4

Closed JackuB closed 9 years ago

JackuB commented 9 years ago

Just encountered this error when running jekyll algolia push

_config.yml:

algolia:
  application_id: '…'
  index_name: '…'

https://github.com/algolia/algoliasearch-jekyll/blob/master/lib/record_extractor.rb#L150

updating algolia index
/Library/Ruby/Gems/2.0.0/gems/algoliasearch-jekyll-0.2.1/lib/record_extractor.rb:150:in `block in weight': undefined method `split' for nil:NilClass (NoMethodError)
    from /Library/Ruby/Gems/2.0.0/gems/algoliasearch-jekyll-0.2.1/lib/record_extractor.rb:150:in `map'
    from /Library/Ruby/Gems/2.0.0/gems/algoliasearch-jekyll-0.2.1/lib/record_extractor.rb:150:in `weight'
    from /Library/Ruby/Gems/2.0.0/gems/algoliasearch-jekyll-0.2.1/lib/record_extractor.rb:174:in `block in extract'
    from /Library/Ruby/Gems/2.0.0/gems/nokogiri-1.6.6.2/lib/nokogiri/xml/node_set.rb:187:in `block in each'
    from /Library/Ruby/Gems/2.0.0/gems/nokogiri-1.6.6.2/lib/nokogiri/xml/node_set.rb:186:in `upto'
    from /Library/Ruby/Gems/2.0.0/gems/nokogiri-1.6.6.2/lib/nokogiri/xml/node_set.rb:186:in `each'
    from /Library/Ruby/Gems/2.0.0/gems/algoliasearch-jekyll-0.2.1/lib/record_extractor.rb:162:in `each_with_index'
    from /Library/Ruby/Gems/2.0.0/gems/algoliasearch-jekyll-0.2.1/lib/record_extractor.rb:162:in `extract'
    from /Library/Ruby/Gems/2.0.0/gems/algoliasearch-jekyll-0.2.1/lib/push.rb:59:in `block in write'
    from /Library/Ruby/Gems/2.0.0/gems/jekyll-2.5.3/lib/jekyll/site.rb:477:in `block (2 levels) in each_site_file'
    from /Library/Ruby/Gems/2.0.0/gems/jekyll-2.5.3/lib/jekyll/site.rb:476:in `each'
    from /Library/Ruby/Gems/2.0.0/gems/jekyll-2.5.3/lib/jekyll/site.rb:476:in `block in each_site_file'
    from /Library/Ruby/Gems/2.0.0/gems/jekyll-2.5.3/lib/jekyll/site.rb:475:in `each'
    from /Library/Ruby/Gems/2.0.0/gems/jekyll-2.5.3/lib/jekyll/site.rb:475:in `each_site_file'
    from /Library/Ruby/Gems/2.0.0/gems/algoliasearch-jekyll-0.2.1/lib/push.rb:56:in `write'
    from /Library/Ruby/Gems/2.0.0/gems/jekyll-2.5.3/lib/jekyll/site.rb:53:in `process'
    from /Library/Ruby/Gems/2.0.0/gems/algoliasearch-jekyll-0.2.1/lib/push.rb:69:in `process'
    from /Library/Ruby/Gems/2.0.0/gems/algoliasearch-jekyll-0.2.1/lib/algoliasearch-jekyll.rb:24:in `block (3 levels) in init_with_program'
    from /Library/Ruby/Gems/2.0.0/gems/mercenary-0.3.5/lib/mercenary/command.rb:220:in `call'
    from /Library/Ruby/Gems/2.0.0/gems/mercenary-0.3.5/lib/mercenary/command.rb:220:in `block in execute'
    from /Library/Ruby/Gems/2.0.0/gems/mercenary-0.3.5/lib/mercenary/command.rb:220:in `each'
    from /Library/Ruby/Gems/2.0.0/gems/mercenary-0.3.5/lib/mercenary/command.rb:220:in `execute'
    from /Library/Ruby/Gems/2.0.0/gems/mercenary-0.3.5/lib/mercenary/program.rb:42:in `go'
    from /Library/Ruby/Gems/2.0.0/gems/mercenary-0.3.5/lib/mercenary.rb:19:in `program'
    from /Library/Ruby/Gems/2.0.0/gems/jekyll-2.5.3/bin/jekyll:20:in `<top (required)>'
    from /usr/bin/jekyll:23:in `load'
    from /usr/bin/jekyll:23:in `<main>'
pixelastic commented 9 years ago

Thanks for the report.

This seems to be caused by the fact that the plugin is unable to find a suitable title for one of your page/post. I'll add protection against that.

In the meantine, would you have an example of one of your page/post that trigger this error ?

pixelastic commented 9 years ago

Anyway, I've just added a fix (pushed as v0.2.2). Tell me if this fixes your issue.