jekyll debug or print all variables jekyll debug or print all variables ruby ruby

jekyll debug or print all variables


With Jekyll 2.x, you can use this plugin.

It allows you to do something like {{ site | debug }}.

Since Jekyll 3, you have {{ variable | inspect }}.


inspect doesn't let you peek inside variables, where jsonify does just that.

{{ variable | jsonify }}

No plugins needed.

Please be aware that jsonify will use as much memory it needs to do its thing without any specific limits. Say, if you have hundreds of posts or pages, and you would want to jsonify them all at once, this may not work as you expect. Worst case the system may go out of RAM and became unresponsive. Exercise due caution.


The other answers don't address the “all variables” part of the question.

Although Jekyll doesn't offer a get_defined_vars equivalent, the documentation does declare all available global variables (which at this time are site, page, layout, content, and paginator).

You can therefore debug/print all variables with a series of jsonify filter calls (filtering also with escape since some of them will contain HTML):

<pre>    site: {{ site | jsonify | escape }}    page: {{ page | jsonify | escape }}    layout: {{ layout | jsonify | escape }}    content: {{ content | jsonify | escape }}    paginator: {{ paginator | jsonify | escape }}</pre>