Use layout for my includes

You can chain layouts. A common convention is to have something like _layouts/default.html which has all the common page wrapper elements you need, <html>, <head>, <body>, etc.

Then you have child layouts that call the default layout but build on it. To do that you have to make use of the {{ content }} tag. A simple example would look something like:

_layouts/default.html

---
---

<html>
  <head>...</head>
  <body>
    {{ content }}
  </body>
</html>

_layouts/child.html

---
layout: default
---

<div class="main">
  {{ content }}
</div>

Then in your pages you’d do something like

page.md

---
title: My page
layout: child
---

Some page content

Which would give you final HTML of:

<html>
  <head>...</head>
  <body>
    <div class="main">
      <p>Some page content</p>
    </div>
  </body>
</html>
1 Like