Variable for the number of posts in a section/blog?

I looked through the docs, trying to find if there’s a variable with the number of posts in a given section, or the entire blog, for that matter, but couldn’t find it.

Does something like this exist?

I use this in my theme to count the number of posts in a section:

{{ len (where .Site.Pages "Section" "posts") }}

You can use other filtering with the where function to count other things, like all posts belonging in a certain category.

With the following you can retrieve the total number of pages (which also includes content that’s not in a section):

{{ len .Site.Pages }}

And this returns the number of posts in all sections, excluding the pages that don’t belong to a particular section:

{{ len (where .Site.Pages "Section" "!=" "") }}

1 Like

That did it, thanks so much!

{{ len .Site.RegularPages }}