Tag links doesn't fork if parent is the homepage

For pages with children you can add tags and below code works great:

<?php $tags = $page->tags()->split(); sort($tags); foreach ($tags as $tag): ?>
  <li><a href="<?= url($page->parent(), ['params' => ['t' => urlencode($tag)]]) ?>" class="button"><?= $tag ?></a></li>
<?php endforeach ?>

But if the actual “Blog” with children is the homepage a link such as http://example.com/home/t:Marketing will be redirected to http://example.com/

I need to make sure if the parent is the homepage that the tag url is http://example.com/t:Marketing which works.

Any suggestions? If I do something like <?php if ($page->parent()->isHomePage()): ?> doesn’t seem to work.

My bad! <?php if ($page->parent()->isHomePage()): ?> does actually work :grin: made a stupid typo :smiley: