I'm somehow stuck and don't find the right way to do it.
I want to output a category list with the number of posts in each categorie.
I got this far: https://paste.xinu.at/dOLtod/
but I never managed to get the real count. I tried so many ways and nothing worked, for example going through each post and checked on every category if it equals {{ category | first }}.
Here is the code without the count:
<ul class="dropdown-menu">
{% for category in site.categories %}
<li class="camelize_me">
<a href="/tags/{{category | first}}/">
{{category | first }}
<span class="badge">
<!-- Post count here -->
</span>
</a>
</li>
{% endfor %}
</ul>
Has anyone an idea to get this done?
I have written a code snippet that not only shows post count in each category, but also navigates to the posts of a specific category which got clicked. I hope you find it helpful:
An incremental improvement over Hossain's answer, which sorts the categories. Tested with Jekyll 3.3.1:
Solution:
{{ category | last }}
has all my posts, so{{ category | last | size }}
displays the count. I got help on the IRC. :)