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?
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With