Display last blog post on homepage using Jekyll

I am trying to display the last blog post on the homepage using Jekyll. All posts + paginator functions work fine on localhost:4000/blog/ , but I would like to repeat this on the main page. The only answer to this question that I saw is in this meaning , which I cannot get.

+4
source share
1 answer

What is the problem with the copied fragment?

It works as follows: in index.html it extracts the first blog post ( site.posts.first ) and stores it in the post variable, and its contents are stored in content . After that, it calls ( include ) the partial post_detail.html , which uses the same context as before.

So, in the end, he uses the first post ( post variable) and its content ( content variable) in the post_detail.html part.

Hope this helps!

+3
source

Source: https://habr.com/ru/post/1499119/


All Articles