How to display a list of links to HTML pages


In my Jekyll site (github pages) I’d like to list links to all subpages in the site.
If I use {{ site.html_pages }} then I get the content of all the subpages, but that’s too much. I’d rather have a list of html links to these pages. Is there a way to produce this?

many thanks,


you can loop thru site.pages and site.posts (I think they are separate?). I do this for the sitemap.

Thanks @rdyar for the hint. Would you have some more details on how to write such a loop?

sure - here is one example of an xml sitemap - loops thru site.pages and then site.posts - not sure where collection would fall in that? but I’m sure they could be sorted out one way or another.

I also use exclude: true in the front matter of a page I don’t want in the sitemap - like an error page.

Thanks a lot @rdyar - with this I was able to build what I needed! :smiley:

is there any such elegant way to make it hierarchical based on the folders?

so, if a page has a permalink of /foo/bar/ it would show under each folder. something like this:

- foo
    - bar
        page title
        another page title
    - log
        yet another page
        and so on
    and on
and the heart goes on...

ps: i don’t know what comes after bar :laughing:

Should be possible with some Liquid-fu

For inspiration check this SO thread for creating breadcrumb links from a page’s path.

You could do something similar looping over the pages you want a menu of, then using split.