If you've found this post by the power of Google it means that you're doing cool things with Shopify Liquid, but you've hit an error. Let's talk quickly about the limit.
There is a limit of 20 unique handles with all_products on a page. As long as you're not pushing any more than 20 you'll never see the error.
The common place I see the Exceeded maximum number of unique handles for all_products error is on related product scripts where theme developers try and loop over every collection, and every product within that. Within those loops sits the all_products tag, getting called every single time. It's pretty easy to hit that 20 limit when you're using it 100s (if not 1000s of time on the one page).
There's no work around here so be sure to design your code around this limit.
Drawbacks to this is that you won't have the content available until after page load but in almost every case this won't be a problem.
If you really need some code examples leave a comment and I'll hack something together.