Skip to content

Instantly share code, notes, and snippets.

@nimbupani
Created December 2, 2011 05:00
Show Gist options
  • Save nimbupani/1421828 to your computer and use it in GitHub Desktop.
Save nimbupani/1421828 to your computer and use it in GitHub Desktop.
Showing latest post on home page with Jekyll
---
layout: default
---
<div class="blog-index">
{% assign post = site.posts.first %}
{% assign content = post.content %}
{% include post_detail.html %}
</div>
<h1 class="entry-title">
{% if page.title %}
<a href="{{ root_url }}{{ page.url }}">{{ page.title }}</a>
{% endif %}
{% if post.title %}
<a href="{{ root_url }}{{ post.url }}">{{ post.title }}</a>
{% endif %}
</h1>
<div class="entry-content">{{ content }}</div>
@lacostenycoder
Copy link

🍻 what he said ^^

@eenblam
Copy link

eenblam commented Jun 20, 2015

Since this is still a topic of interest several years later, it's probably worth mentioning the Jekyll Bootstrap docs.

@cherrot
Copy link

cherrot commented Jul 11, 2015

Awesome hack!

@onewithnow
Copy link

Works! Thank you so much.

@TangChr
Copy link

TangChr commented Oct 12, 2015

Works like a charm. Thanks!

@mhlibchuk
Copy link

Hi there, I know I'm a bit late, but thanks! Just what I was looking for.

@terrencebrown
Copy link

many thanks buddy!

@pabloselin
Copy link

Thanks! this helped me understand Jekyll and get started with some templating...

@michelinux
Copy link

Thank you. Just what I was looking for. Even after so many years.

@BradCoffield
Copy link

Thanks a lot. I just needed a simple link to the latest post and reading your stuff helped me.

Just FYI for others: <a href="{{site.posts.first.url}}">{{site.posts.first.title}}</a>

@bildungsroman
Copy link

I know this is a bit late, but now how do you show the rest of your posts if you're using pagination? I know an easy way would be to do offset:1, but with pagination this offsets the first post on each page, which is not what I want. Is there a way to use assign, i.e. {% assign remainingposts = site.posts offset:1 %} or something like that?

@crnkofe
Copy link

crnkofe commented Dec 2, 2020

I just added this into _layouts/home.html . Works like a charm.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment