How to show the latest post as the homepage?


#1

How do I go about showing the latest post as the homepage? I am not talking about only showing the latest post with a loop, instead the latest post itself should become the homepage every time a post is published.
Is it possible to achieve this with liquid? I am relatively new to Jekyll, not quite sure how to go about it.


#2

why not? you just need to make sure they us the same sort of layout and then it shouldn’t be much trouble. Note that in the layout where it has {{content}} you will need to have your loop item content instead. So I guess it needs it’s own layout? depends on what all you have in the layout.

I think you’ll need to use limit:1 to get just the most recent post.

Try it and see how far you get, then post what you did and what is wrong. A link to a repo would be helpful.


#3

See this thread for ideas

You can access the first of last post of the site.posts object. You can then make a modified layout or just put all the logic in your home index page.

Depending on what sort of content you want to display this will vary. But at its most basic level this would output the latest post’s title and body content… without looping… which is good for your build time.

<h1>{{ site.posts.last.title }}</h1>
{{ site.posts.last.content }}