There is nothing to stop you from doing this. In the above script, yourdomain.tld / pages / prent1 / son1.html will be the URL of the parent1 / son1 file.
Creating a nested list, however, will be more complicated. You can either type this structure into the YAML Front Matter, or use messages.
pages |-> parent1 |-> _posts/ |-> index.html |-> son1.html |-> son2.html |-> parent2 |->_posts |-> index.html
=> This way your files will be messages in the categories parent1 and parent2, and you can create a list by specifying the categories and their contents.
If you really want to display the tree structure without using messages and categories, you will need to do more black magic. But, fortunately, Liquid offers a split filter, which can be used to split the site path into pieces, for example.
{% for page in site.pages %} {{ page.url | split:'/' | join:'+'}} {% endfor %}
Instead of joining them (this is just for demonstration), you want to populate an array that contains a tree structure, and then iterate over that array to display the directory tree. It is possible, but not easy. And I do not think that there is something easily accessible.
It’s probably easier to write a plugin.
source share