I have 3 different _layouts.
I can show all my post on the index.html but they all have the same layout. Can I somehow show multiple layouts on the same page (index.html)?
A page can have only one layout
, but layouts can be nested.
I have three _layouts
:
The master
layout has all of the basic structure that any page I want will need. It looks
something like this:
<html>
<head>
<title>{{ page.title }}</title>
</head>
<body>
{{ content }}
</body>
</html>
I use the default
layout for most pages that are not blog posts. I do make extensive use
of a few page
variables in pages' YAML front matter. The layout looks something like this:
---
layout: master
---
<h1>
{{ page.title }}
{% if page.subtitle %}<small>{{ page.subtitle }}</small>{% endif %}
</h1>
{% if page.description %}<p>{{ page.description }}</p>{% endif %}
{{ content }}
I use the post
layout for _posts
pages. It looks like this:
---
layout: default
---
<p>Posted {{ page.date }}</p>
<ul>{% for tag in page.tags %}...{% endfor %}</ul>
{{ content }}
Every blog post that I make, I use the post
layout, and they inherit from all three layouts.
If you want to have snippets of reusable markup, then I would recommend using
_includes
.
A page can only have one layout. What you need is _includes, which you can use wherever a post is to be displayed.
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