title |
---|
Commands |
As of version 2.5.0, Jekyll can be extended with plugins which provide
subcommands for the jekyll
executable. This is possible by including the
relevant plugins in a Gemfile
group called :jekyll_plugins
:
{% highlight ruby %} group :jekyll_plugins do gem "my_fancy_jekyll_plugin" end {% endhighlight %}
Each Command
must be a subclass of the Jekyll::Command
class and must
contain one class method: init_with_program
. An example:
{% highlight ruby %} class MyNewCommand < Jekyll::Command class << self def init_with_program(prog) prog.command(:new) do |c| c.syntax "new [options]" c.description 'Create a new Jekyll site.'
c.option 'dest', '-d DEST', 'Where the site should go.'
c.action do |args, options|
Jekyll::Site.new_site_at(options['dest'])
end
end
end
end end {% endhighlight %}
Commands should implement this single class method:
Method | Description |
---|---|
|
This method accepts one parameter, the
|