How to render a Jekyll markdown page on sites index

There are a few things going on here.

  1. In your _layouts/default.html file (and any of the other _layouts directory files for that matter), instead of:

    {{ page.content }}
    

    you need to use:

    {{ content }}
    
  2. Jekyll only lets you includes files from a site root level _includes directory. So, you need to move your content.md from the root to that directory (making it if it doesn’t already exist).

  3. Finally, you need to actually make the call to the include file from your index.html file. This can be done by changing the content of your index.html file to:

    ---
    layout: default
    ---
    
    {% include content.md %}
    

That will setup the behavior you are looking for.


I’d point out two other things:

  1. You may find that changing the extension of your index file from .html to .md works better. An important note though: you need to use .html if you want pagination. Per the Jekyll Pagination documentation, that feature only works when the file is named index.html.

  2. If all you are doing in your index file is calling an include that only resides on that page, you might be just as well off simply putting the content directly in the index file.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)