Search code examples
markdownjekyll

Render all markdown files in an html page in jekyll


I have got an html page and a bunch of markdown files. I want the content of the files rendered in my page. Generally, one would have the layout specified in the front matter of his markdown file and let that markdown file become an independent page. But, I don't want that. I have a single html page. I want to iterate through all the markdown files and display their content on the html page. Is there a way to do this? I tried-

{%for file in site.files%}
    {{file.content}}
    <br>
    <hr>
{%endfror%}

But, I think I can't use file.content to access the content of a markdown file.


Solution

  • Make your markdown files a collection. Then you can loop the collection and access the file content.

    {% for file in site.collection_name %}
        {{ file.content }}
        <br>
        <hr>
    {% endfor %}