Taxonomy pages do not allow custom collections

I am trying to pull together a custom collection of all item pages (articles in a blog):

{% set my_pages = page.collection({
‘items’: ‘@root.descendants’,
‘order’: {
‘by’: ‘random’,
‘dir’: ‘desc’,

I would assume that no matter on what page I execute this and then run
{{ dump(count(my_pages)) }} - I always get the same count (in our example, let’s say I have 50 item pages which have different categories). However, the behavior is a bit different.

  • on the blog page it shows the correct count of pages (50)
  • on an inidivudal item page, it also shows correct count of pages (50)
  • however, if I run this code on a taxonomy listing page: - the count only shows the number of items in category blue (ex: 5)

Do I misunderstand how my custom collection works or do you know why it will not show count 50 on the category page?

thanks much

@swimator, By default, Grav applies the url.params to collections. To alter this behaviour you can use option url_taxonomy_filters: boolean in your collection definition, or change the default in system.yaml using pages:url_taxonomy_filters: boolean.

Try the following:

{% set my_pages = page.collection({
    'items': '@root.descendants',
    'order': {
        'by': 'random',
        'dir': 'desc',
    'url_taxonomy_filters': false,

NB. I think the following would be a more suitable title for your post: “Prevent custom collection being filtered by query params”

@pamtbaau - wow, thanks a lot. It works like a charm.

Perhaps this is something that should be part of the documentation for Page Collections since it is a little counter-intuitive to put some hidden filter onto a custom made collection.

Btw, you are right about the title, but I cannot seem to change it anymore.