How to include HTML file in markdown file in jekyll?

I have a jekyll site with this structure:

▾ _includes/ post-entry.html ▾ _posts/ 2012-11-25-first-post.markdown index.markdown 

In my index.markdown, I want to include post-entry.html as follows:

 {% for post in site.posts %} * {% include post-entry.html %} {% endfor %} 

But it looks like a piece of HTML code on a blog. How can i prevent the html code? protected?

+7
source share
4 answers

You can use liquid tags in any markdown file if it has a YAML header value. For example, check index.md specified in the jekyllbootstrap template for Jekyll sites .

If you reference your actual index.markdown or your repository (for example, if it is on github), we could better understand what went wrong. Your example should work, although you may need to use the HTML <li> list element rather than markdown * .

+12
source

The problem is that the parser treats HTML as code blocks. The best way would be to disable code blocks like the ones I asked in this question

To work, use the replace tag:

 {% capture includeGuts %} {% include post-entry.html %} {% endcapture %} {{ includeGuts | replace: ' ', ''}} 
+4
source

Use {{ post.content }} instead.

Here is the code that I use on my website as an example:

 {% for post in site.posts %} <a href="{{ post.url }}"> <h2>{{ post.title }} &mdash; {{ post.date | date_to_string }}</h2> </a> {{ post.content }} {% endfor %} 
0
source

You can not. Markdown files are simply text files with style. If you want to use Liquid tags, you will need to do this in your _layouts

If I correctly guess that you want this markup file on your index page? Therefore, in the default.html layout, after the {{content}} tags, you can use the fluid tags you want to use. No need to mix markup files with code.

-7
source

All Articles