You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A simple liquid tag for debugging Jekyll sites with a fancy debugger console.
Installation
If you're using bundler add this gem to your site's Gemfile in the :jekyll_plugins group:
group :jekyll_plugins do
gem 'octopress-debugger'
end
Then install the gem with Bundler
$ bundle
To install manually without bundler:
$ gem install octopress-debugger
Then add the gem to your Jekyll configuration.
gems:
- octopress-debugger
Usage
Add the {% debug %} tag to any page to get access to the debugger console when that page is generated.
This will launch an interactive debugging console where you can do some cool things.
Some useful debugger commands:
continue - to go to the next {% debug %} tag, or step through a loop.
abort - to exit the debugger.
help - show manual for the debugger and learn other commands.
I've added some convenience methods for working with the Liquid context.
c - Liquid's context
site - Jekyll's Site class instance.
page - Current Page class instance.
scopes - Scopes for local variables.
You can pass strings to the c method to inspect variables.
c'site'# => current site payload hashc'page'# => current page payload hash
Dot notation works too:
c'site.pages'# => Array of site postsc'site.posts.first'# => First post instance in site posts arrayc'page.layout'# => Read data from current pagec'foo'# => Read locally assigned vars
Example:
Debugging is a great way to learn about how Jekyll works. For example, you can step through a for loop like this.
{% assign test='awesome' %}
{% for post in site.posts %}
{% debug %}
{% endfor %}
In the debugger you can type scopes to see a hash representing variables in the for loop. Here's a look at what you might see: