A collection knows its own size. is the total number of products in it, precomputed by Shopify.
<a href="{{ collection.url }}">
{{ collection.title }} ({{ collection.products_count }})
</a>
It is tempting to write collection.products | size instead. Don't. Shopify loads products in pages of 50, so size counts only the loaded page and silently caps at 50 on a bigger collection.
products_count is the true total at any size. | size is the AI tell that breaks the day a catalog grows past 50.