Search code examples
rubyjekyllliquidgithub-pages

Jekyll - split content up into two columns


I have a basic layout page template:

---
layout: default
---

<header class="sidebar">
    {{ page.title }}
</header>

<section class="content">
    {{ content }}
</section>

My pages that use this as the page template are just Markdown that gets put into the <section> block.

I'm looking for a way to keep all my page content in one file but have it so I can define separate content that gets put into the <header> tag from the page template.

Is there any way to do this and keep all the page's content in one file?


Solution

  • You can do so by defining the content you wish to be separate and reused in the _includes/ directory.

    You would then include it by calling for example: {% include file.ext %} to include the of the file name _includes/file.ext (almost as if you just copy and pasted it in).

    See section pertaining to the _includes in the Jekyll documentation here.