# Display last item of a collection

**URL:** <https://talk.jekyllrb.com/t/display-last-item-of-a-collection/2605>\
**Category:** Help\
**Created:** [February 8, 2019, 12:51am UTC](https://talk.jekyllrb.com/t/display-last-item-of-a-collection/2605 "2019-02-08T00:51:08Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![mmistakes](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.jekyllrb.com/mmistakes/32/2169_2.png) [@mmistakes](https://talk.jekyllrb.com/u/mmistakes)\
**Post date:** [February 8, 2019, 4:24am UTC](https://talk.jekyllrb.com/t/display-last-item-of-a-collection/2605/3 "2019-02-08T04:24:44Z")

</div>

This may work for you. It’s a quick way to get at first and last posts. And since posts are a collection I’m thinking it will.

> [@Question about site.posts values](http://talk.jekyllrb.com/t/question-about-site-posts-values/1972/6):
>
> Oh and even simpler are [first](https://shopify.github.io/liquid/filters/first/) and [last](https://shopify.github.io/liquid/filters/last/). Use dot notation and you can access the entire object. In your case {{ site.posts.first.title }} and {{ site.posts.last.title }} will get the title of the first and last posts. You can replace title with any variable available in the post’s YAML Front Matter… date, content, excerpt, etc.

You just might need to do an `assign` on the collection first to `sort` it. Then you can `.first` on that sorted array.

---

_[View the full topic](https://talk.jekyllrb.com/t/display-last-item-of-a-collection/2605)._
