Thanks a lot!
Unfortunately, the suggested line also causes the page to go offline. However, I found a former topic that helped solving the issue (sorry for missing that before).
The code that actually worked goes like this:
<a href="<?= url($page->url(), ['params' => ['tag' => $tag]]) ?>" <?php e($tag === param('tag'), 'class="active"', '') ?>><?= html($tag) ?></a>
What I did not communicate clearly enough though was that I want the selected tag to be styled differently. To achieve this, I replaced class="active"
by class="current"
and added css accordingly. Now everything works as I want it to:
<ul class="tags">
<?php foreach($tags as $tag): ?>
<li>
<a href="<?= url($page->url(), ['params' => ['tag' => $tag]]) ?>" <?php e($tag === param('tag'), 'class="current"', '') ?>><?= html($tag) ?></a>
</li>
<?php endforeach ?>
</ul>