Jekyll index.html that uses 3 different _layouts

I have 3 different _layouts.

  • post-link.html
  • post-article.html
  • after photo.html

I can show my entire post in index.html, but they all have the same layout. Can I somehow show multiple layouts on the same page (index.html)?

+7
source share
2 answers

A page can have only one layout , but layouts can be nested.

I have three _layouts :

  • master.html
  • default.html
  • post.html

The master layout has the entire basic structure that is needed for any page. 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 make extensive use of several page variables in the front of YAML pages. 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 am using 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 I make, I use a post layout, and they inherit all three layouts.

If you want to have reusable markup fragments, then I would recommend using _includes .

+19
source

There can only be one layout per page. What you need is _includes, which you can use wherever the message should be displayed.

+2
source

All Articles