Thanks @pixelijn
I got the idea but had problems with
! $page->hasParent()
Looks like this condition is applied even when I browse the “Blog” page and I get the following error
Call to a member function on null
<?= $page->parent()->title()->html(); ?>
if I visit the “article” page this works like a charm
Looks like this might have a similar issue as described here.
I got things working with $page->parents()->count() and solution looks like this
<?php if( $page->isHomePage() === false && ! $page->parents()->count() ) : ?>
<?= $page->title()->html(); ?>
<?php elseif( $page->isHomePage() === false && $page->parents()->count() ) : ?>
<?= $page->parent()->title()->html(); ?>
<?php else : ?>
// Do nothing
<?php endif ?>
Really like the shorthand version but I have no idea how to add one more if statement