Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Howto find the sum of values from posts' in Jekyll frontmatter

In each of my Jekyll posts, I have a number listed in the front matter:

---
minutes: X
---

The value is always different from post-to-post and I would like to find the sum of all the posts.

Not sure if this is possible or what the approach should be.

Thanks for any help in advance!

like image 863
teleject Avatar asked Nov 02 '25 12:11

teleject


1 Answers

Try:

{% assign total = 0 %}
{% for post in site.posts %}
  {% assign total = total | plus: post.minutes %}
{% endfor %}
{{ total }}
like image 102
David Jacquel Avatar answered Nov 04 '25 18:11

David Jacquel