pattex / jekyll-tagging

Jekyll plugin to automatically generate a tag cloud and tag pages.
385 stars 76 forks source link

Issue with plugin loading/execution order? #42

Open nhoizey opened 9 years ago

nhoizey commented 9 years ago

I don't know where this error comes from, I get the following message:

$ ./_build.sh                                                                                               *?[master] 
Configuration file: ./_config.yml
  Liquid Exception: undefined method `config' for nil:NilClass in _layouts/archives-year.html
rake aborted!
NoMethodError: undefined method `config' for nil:NilClass
/usr/local/lib/ruby/gems/2.2.0/gems/jekyll-tagging-1.0.1/lib/jekyll/tagging.rb:133:in `tag_url'
/usr/local/lib/ruby/gems/2.2.0/gems/jekyll-tagging-1.0.1/lib/jekyll/tagging.rb:140:in `block in tags'
/usr/local/lib/ruby/gems/2.2.0/gems/jekyll-tagging-1.0.1/lib/jekyll/tagging.rb:140:in `map!'
/usr/local/lib/ruby/gems/2.2.0/gems/jekyll-tagging-1.0.1/lib/jekyll/tagging.rb:140:in `tags'
/usr/local/lib/ruby/gems/2.2.0/gems/liquid-2.6.3/lib/liquid/strainer.rb:43:in `invoke'
/usr/local/lib/ruby/gems/2.2.0/gems/liquid-2.6.3/lib/liquid/context.rb:82:in `invoke'
/usr/local/lib/ruby/gems/2.2.0/gems/liquid-2.6.3/lib/liquid/variable.rb:50:in `block in render'
/usr/local/lib/ruby/gems/2.2.0/gems/liquid-2.6.3/lib/liquid/variable.rb:38:in `each'
/usr/local/lib/ruby/gems/2.2.0/gems/liquid-2.6.3/lib/liquid/variable.rb:38:in `inject'
/usr/local/lib/ruby/gems/2.2.0/gems/liquid-2.6.3/lib/liquid/variable.rb:38:in `render'
/usr/local/lib/ruby/gems/2.2.0/gems/liquid-2.6.3/lib/liquid/block.rb:109:in `block in render_all'
/usr/local/lib/ruby/gems/2.2.0/gems/liquid-2.6.3/lib/liquid/block.rb:96:in `each'
/usr/local/lib/ruby/gems/2.2.0/gems/liquid-2.6.3/lib/liquid/block.rb:96:in `render_all'
/usr/local/lib/ruby/gems/2.2.0/gems/liquid-2.6.3/lib/liquid/tags/for.rb:117:in `block (2 levels) in render'
/usr/local/lib/ruby/gems/2.2.0/gems/liquid-2.6.3/lib/liquid/tags/for.rb:105:in `each'
/usr/local/lib/ruby/gems/2.2.0/gems/liquid-2.6.3/lib/liquid/tags/for.rb:105:in `each_with_index'
/usr/local/lib/ruby/gems/2.2.0/gems/liquid-2.6.3/lib/liquid/tags/for.rb:105:in `block in render'
/usr/local/lib/ruby/gems/2.2.0/gems/liquid-2.6.3/lib/liquid/context.rb:112:in `stack'
/usr/local/lib/ruby/gems/2.2.0/gems/liquid-2.6.3/lib/liquid/tags/for.rb:104:in `render'
/usr/local/lib/ruby/gems/2.2.0/gems/liquid-2.6.3/lib/liquid/block.rb:109:in `block in render_all'
/usr/local/lib/ruby/gems/2.2.0/gems/liquid-2.6.3/lib/liquid/block.rb:96:in `each'
/usr/local/lib/ruby/gems/2.2.0/gems/liquid-2.6.3/lib/liquid/block.rb:96:in `render_all'
/usr/local/lib/ruby/gems/2.2.0/gems/liquid-2.6.3/lib/liquid/block.rb:82:in `render'
/usr/local/lib/ruby/gems/2.2.0/gems/liquid-2.6.3/lib/liquid/template.rb:128:in `render'
/usr/local/lib/ruby/gems/2.2.0/gems/liquid-2.6.3/lib/liquid/template.rb:138:in `render!'
/usr/local/lib/ruby/gems/2.2.0/gems/jekyll-2.5.3/lib/jekyll/convertible.rb:106:in `render_liquid'
/usr/local/lib/ruby/gems/2.2.0/gems/jekyll-2.5.3/lib/jekyll/convertible.rb:205:in `render_all_layouts'
/usr/local/lib/ruby/gems/2.2.0/gems/jekyll-2.5.3/lib/jekyll/convertible.rb:239:in `do_layout'
/usr/local/lib/ruby/gems/2.2.0/gems/jekyll-archives-2.0.0/lib/jekyll-archives/archive.rb:104:in `render'
/usr/local/lib/ruby/gems/2.2.0/gems/jekyll-archives-2.0.0/lib/jekyll-archives.rb:96:in `block in render'
/usr/local/lib/ruby/gems/2.2.0/gems/jekyll-archives-2.0.0/lib/jekyll-archives.rb:95:in `each'
/usr/local/lib/ruby/gems/2.2.0/gems/jekyll-archives-2.0.0/lib/jekyll-archives.rb:95:in `render'
/usr/local/lib/ruby/gems/2.2.0/gems/jekyll-archives-2.0.0/lib/jekyll-archives.rb:40:in `generate'
/usr/local/lib/ruby/gems/2.2.0/gems/jekyll-2.5.3/lib/jekyll/site.rb:280:in `block in generate'
/usr/local/lib/ruby/gems/2.2.0/gems/jekyll-2.5.3/lib/jekyll/site.rb:279:in `each'
/usr/local/lib/ruby/gems/2.2.0/gems/jekyll-2.5.3/lib/jekyll/site.rb:279:in `generate'
/usr/local/lib/ruby/gems/2.2.0/gems/jekyll-2.5.3/lib/jekyll/site.rb:50:in `process'
/Users/nhoizey/Dropbox/Personnel/Devs/nicolas-hoizey.com/Rakefile:15:in `block (2 levels) in <top (required)>'
Tasks: TOP => site:index => site:generate
(See full trace by running task with --trace)

The trace shows it happens in /usr/local/lib/ruby/gems/2.2.0/gems/jekyll-tagging-1.0.1/lib/jekyll/tagging.rb:133:in 'tag_url'

My source code is here: https://github.com/nhoizey/nicolas-hoizey.com

I first opened this issue in the jekyll-archive project: https://github.com/jekyll/jekyll-archives/issues/49

There, @alfredxing told me this:

Although I'm not familiar with the jekyll-tagging plugin, it seems like that plugin is being initialized after jekyll-archives in this case, which means you can't use the tags filter in an archive page.

You might want to raise the issue with the developer of that plugin. I believe it's possible to access the site config in a Liquid filter (using Liquid context registers) without needing to initialize the generator first.

Any hints? Thanks in advance for your help.

parkr commented 9 years ago

Try playing with the priority flag.