jekyll debug or print all variables

thoth picture thoth · Dec 2, 2015 · Viewed 12.7k times · Source

I want to peak into Jekyll's brain and see what's going on, in php you have get_defined_vars, so I tried to do something akin to that with:

      {% for local_variable in local_variables %}
      <p> {{ local_variable }} </p><br>
      {% endfor %}

Which output nothing. Am I trying too hard? Is there some method in ruby or jekyll for this? I'd just like to poke around and make sure everything is set correctly and possibly to find out about variables I don't know about.

Answer

David Jacquel picture David Jacquel · Dec 2, 2015

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 }}.