Reference

Guide

$page->isActive()

Checks if the page is the current page

$page->isActive(): bool

Return type

bool

Example

<nav role="navigation">
  <ul>
    <?php foreach($pages as $subpage): ?>
    <li<?php e($subpage->isActive(), ' class="active"') ?>>
      <a href="<?= $subpage->url() ?>">
        <?= html($subpage->title()) ?>
      </a>
    </li>
    <?php endforeach ?>
  </ul>
</nav>

Source code

kirby/src/Cms/Page.php#L552