|JULY 2019 UPDATE: Chris Oliver was able to contribute to the Jekyll documentation. Now the official tutorial doc has a recursive Jekyll ToC. Yay!|None of the examples of site navigation in the
use recursion to go more than 3 levels deep. And I couldn’t find a
method on the interwebs that was exactly what I wanted, although
pretty close. Here, expanding on the method in
Chris Oliver’s old 2011 post,
this method passes the subtree as a parameter to the recursive call.
For example, let’s say you create a data file called
And you create an include file named
tree.html (accepting the passed tree param in
include.tree on line 2 and recursion on line 4).
You can then kick the whole thing off with a table of contents that includes the
tree.html include file, passing
site.data.contents.tree as its tree parameter.