Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I debug plugins that are being silently ignored?

Newcomer to Jekyll here (previously on Hyde).

  • Ruby files placed in the _plugins/ directory are apparently silently ignored.
  • I am using version 0.11.2 of Jekyll, with ruby 1.8.7 on Ubuntu 12.04.

Should an extra config parameter be added to load these plugins? The doc doesn't say so - the sane default should be to look into _plugins, and they should be required automatically. How can one debug the loading of Jekyll plugins?

like image 914
castdoctor Avatar asked Jun 16 '12 08:06

castdoctor


2 Answers

For my instance of jekyll (also 0.11.2, but with ruby 1.9.2p290 on a Mac), I don't have to add any extra configuration, but you can try adding the following line to your top level "_config.yml" file.

plugins:     _plugins

or, possibly,

plugins:     ./_plugins

The simplest way to test that your plugins are working is to remove all of them except for one that you know will work. I've put together the following which works as expected on my install.

  1. Create a new file in the root of your jekyll source directory called "plugin_test.md" with the following contents:

    ---
    layout: default
    title: Plugin Test
    ---
    
    the quick brown fox jumps over the lazy dog.
    
    Testing plugin output of '_plugins/testplugin.rb': {% testplugin %}
    

    Note that you may need to change "layout: default" to whatever you are actually using.

  2. Create a new file at "_plugins/testplugin.rb" with the following contents:

    module Jekyll
      class TestPlugin < Liquid::Tag
        def render(context)
          "It's Working!"
        end
      end
    end
    
    Liquid::Template.register_tag('testplugin', Jekyll::TestPlugin)
    
  3. Run jekyll on your source dir.

All that testplugin.rb does is replace instances of the liquid tag {% testplugin %} with the text "It's Working!". If your plugins are triggering, you'll see the output

Testing plugin output of '_plugins/testplugin.rb': It's Working!" 

on the page "plugin_test.html" at your output site root. If you see:

Testing plugin output of '_plugins/testplugin.rb':

that means that the plugin didn't trigger. If you run into that, I think it's a sign that something is pretty out of whack and would advise reinstalling jekyll.

like image 88
Alan W. Smith Avatar answered Nov 15 '22 09:11

Alan W. Smith


I know I'm little bit late but for others who still come across this question I would like to add my resolution: Restart the server to get the newly added plugin working. So stop jekyll serve (Ctrl C) and restart it again with jekyll serve.

like image 22
Sven Avatar answered Nov 15 '22 10:11

Sven