Best and most performant way to create a filter for news articles on different subpages

I’m building a website for my sports club. This club has different departments, e.g. track and field, handball. Each department has a dedicated news section where news articles of that department are located. A news section is a special template type that shows a paginated view of all the articles of that department. News for the track and field department for examples can be found under On the websites homepage I now want to show a list of teasers to the latest articles of all departments. Therefore I added a field department (type is tag) to the news story blueprint to allow to tag every news article to its department. At the moment I select the latest articles via the following filter:

$kirby->site()->index()->filterBy('template', "story")->filterBy('departments', 'in', $departmentsToFilter->split(','), ',')->sortBy('modified', 'desc')->limit($this->count()->value());

This is at least up to now very performant (but I only have a few test pages by now). In the docs it says to be careful when using site()->index(), because it could slow down the page remarkably when the site has a lot of pages. Is there a better way to write a filter that selects the latest news articles combined from all departments?
Do I have to create a filter query for each new section of every department, combine the resulting pages in an array and then filter them by date? Is this at least in the long run more performant?
I’d appreciate any tips and best practices to achieve my goal.

Best regards.


from my experience the filter operation is less an issue than reading the content files once you pass more than a few hundered pages. i would suggest adding cache (see examples here) around the result to perform it less often (idealy only if the source changed).

1 Like

Thank you @bnomei ,
that sound reasonable. Then I’ll keep that filter and try to to cache the results as you proposed.