The bin/run_this_first
script customizes your new Jekyll plugin gem.
It does the following:
- Renames the Jekyll template, including directories, files and contents.
- Deletes itself, its tests and its test data.
- Does not delete tests for the Jekyll plugin.
- Deletes this README.md and renames
PLUGIN_README.md
toREADME.md
. - Initializes a new local git repository and optionally creates a public or private project on GitHub.
- Provides scripts for building and testing your new Jekyll plugin gem locally.
- Provides settings for Visual Studio Code, Rake, Rubocop and RSpec.
The customized gem is ready to be pushed to RubyGems.org
, or any other Ruby gem repository, whenever your feel ready.
- Setting Up a Ruby Development Environment
- Working with Jekyll Plugins as Ruby Gems
- Making a Jekyll Plugin as a Ruby Gem
- Debugging Jekyll Plugins with an IDE
- Installing Rubocop As a Development Dependency
- Jekyll Plugin Template Collection
-
Clone this repo into a directory called
my_plugin
, or whatever you want to call your plugin.$ git clone https://github.com/mslinn/jekyll_plugin_template.git my_plugin
Or, if you have forked the project, replace
mslinn
below with your GitHub user id:$ git clone [email protected]:mslinn/jekyll_plugin_template.git my_plugin
-
Change directory to the new plugin project:
$ cd my_plugin
-
Run the customization script and answer the prompts.
$ bin/run_this_first
-
Open the project in Visual Studio Code and explore the project:
$ code .
-
Build the plugins provided with this template.
$ bundle exec rake install
-
You can now use your new Jekyll plugins in a Jekyll website.
a) Add the following to your Jekyll website's
Gemfile
. The installation script had you rename the plugin template fromjekyll_plugin_template
to a name of your choosing. Use that name instead below:group :jekyll_plugins do gem 'jekyll_plugin_template' end
b) Add the following you your Jekyll website's
_config.yml
to set log levels for each type of plugin from the template. Customize the log levels as desired:plugin_loggers: CleanHook: info DocumentHooks: warn MyBlock: info PageHooks: warn PostHooks: warn PluginMetaLogger: info SiteHooks: info
-
Delete the portions of the template that you do not need.
-
Debug the Jekyll plugin if required.
-
Publish the gem when ready:
$ bundle exec rake release
Please see the blog post about this {% href https://mslinn.com/blog/2022/03/28/jekyll-plugin-template-collection.html Jekyll plugin gem template %}.
The Jekyll documentation does not indicate the exact order that each of the 45 hooks gets called.
However, the log output from this template makes that clear.
Following is elided output; I removed duplicate log entries.
All loggers were set to level info
.
Output will vary, depending on the Jekyll site that is processed and the log levels you set.
:post_init
, in particular, gets called many times.
INFO Module: Jekyll::Hooks.register(:site, :after_reset) invoked.
INFO Module: Jekyll::Hooks.register(:pages, :post_init) invoked.
INFO Module: Jekyll::Hooks.register(:documents, :post_init) invoked.
INFO Module: Jekyll::Hooks.register(:posts, :post_init) invoked.
INFO Module: Jekyll::Hooks.register(:site, :post_read) invoked.
INFO Module: Jekyll::Hooks.register(:pages, :post_init) invoked.
INFO Module: Jekyll::Hooks.register(:site, :pre_render) invoked.
INFO Module: Jekyll::Hooks.register(:pages, :pre_render) invoked.
INFO Module: Jekyll::Hooks.register(:pages, :post_convert) invoked.
INFO Module: Jekyll::Hooks.register(:pages, :post_render) invoked.
INFO Module: Jekyll::Hooks.register(:site, :post_render) invoked.
INFO Module: Jekyll::Hooks.register(:clean, :on_obsolete) invoked for [].
INFO Module: Jekyll::Hooks.register(:pages, :post_write) invoked.