kirqe
kirqe

Reputation: 2470

How to display some of the posts in specific places on page?

I want to display a specific post in the middle of the page among other regular posts(check screenshot)

I know I could use front matter with something like featured: true but is there any other way to do this?

enter image description here

Upvotes: 1

Views: 102

Answers (2)

Mr. Hugo
Mr. Hugo

Reputation: 12592

Better answer: create similar divs around each post, and target them with CSS like this:

div {width: 50℅;}
div:nth-child(1), div:nth-child(4) {width: 100%;}

Layout should be in CSS, if possible.

Upvotes: 1

Mr. Hugo
Mr. Hugo

Reputation: 12592

Simple. Just do this:

{% for post in site.posts %}
  {% if forloop.index == 1 or forloop.index == 4 %}
    output wide post
  {% else %}
    output normal post
  {% endif %}
{% endfor %}

Upvotes: 2

Related Questions