How to get latest post date in category page?

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.

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

maybe:

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

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:

1 Like

Excellent solution @mmistakes

Really thank you so much michael