# How to get latest post date in category page?

**URL:** <https://talk.jekyllrb.com/t/how-to-get-latest-post-date-in-category-page/2884>\
**Category:** Help\
**Created:** [May 5, 2019, 6:38am UTC](https://talk.jekyllrb.com/t/how-to-get-latest-post-date-in-category-page/2884 "2019-05-05T06:38:43Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Goyllo](https://avatars.discourse-cdn.com/v4/letter/g/e9a140/32.png) [@Goyllo](https://talk.jekyllrb.com/u/Goyllo)\
**Post date:** [May 5, 2019, 6:38am UTC](https://talk.jekyllrb.com/t/how-to-get-latest-post-date-in-category-page/2884/1 "2019-05-05T06:38:43Z")

</div>

I’ve some post with specific category, and I generate that category page manually using below codes.

```
    {% for post in site.categories.myCategory %}
      <li class="post_list">
         <h2><a href="{{ post.url | prepend: site.baseurl }}">{{ post.title }}</a></h2>
		<p>{{ post.content }}</p>
      </li>
    {% endfor %}

```

As you know post always have some date, and I want to display my latest post date in my category page. _Here latest post means latest post in specific category(myCategory), not the latest one from all category_

For example my latest post is `2019-05-05-exxample.md` so I want to display 5 may 2019 in my category page.

`{{ site.time }}` gives me latest build date, but I want that date on which I’ve published specific post on specific category page. Right now I’m using date frontmatter in my category page and then get the date via `{{ page.date | date_to_string}}`, but whenever I published new post on myCategory page, then I’ve to change the date on my front matter manually, so I’m looking for automatic solution which fetch latest post date on specific category page.

---

<div class="post-metadata">

**Author:** ![rdyar](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.jekyllrb.com/rdyar/32/710_2.png) [@rdyar](https://talk.jekyllrb.com/u/rdyar)\
**Post date:** [May 10, 2019, 4:23am UTC](https://talk.jekyllrb.com/t/how-to-get-latest-post-date-in-category-page/2884/2 "2019-05-10T04:23:08Z")

</div>

so you want the date of the most recent post, but not really with the post - you want it on the page somewhere?

maybe:

```auto
 {% for post in site.categories.myCategory limit:1 %}
Most recent post: {{post.date}}
{% endfor%

```

---

<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:** [May 10, 2019, 12:31pm UTC](https://talk.jekyllrb.com/t/how-to-get-latest-post-date-in-category-page/2884/3 "2019-05-10T12:31:28Z")

</div>

You can directly access the first and last post objects this way, eliminating the need for the `for` loop. See this thread for more info:

> [@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.

---

<div class="post-metadata">

**Author:** ![Goyllo](https://avatars.discourse-cdn.com/v4/letter/g/e9a140/32.png) [@Goyllo](https://talk.jekyllrb.com/u/Goyllo)\
**Post date:** [May 10, 2019, 1:08pm UTC](https://talk.jekyllrb.com/t/how-to-get-latest-post-date-in-category-page/2884/4 "2019-05-10T13:08:28Z")

</div>

Excellent solution @mmistakes

Really thank you so much michael
