Feeling Lucky Craft Pagination


I've implemented a google-like "Feeling lucky!" on this blog's pagination. At current date, there are 21 total pages of entries. It's a toss of the dice whether or not any of them are actually worth reading, so I thought to make the gamble easier, I'd provide a random number to automatically populate the url for you. Here's the code:

{% set randomPage = random(pageInfo.totalPages) %}
<a href="pageInfo.getPageUrl( randomPage )">Feeling Lucky! Take me to a Random Page</a>