Write a ‘title’ helper 

hook 'before' => sub {
    %global = ( # Reset tokens for this request
        tokens => {
            title => setting('appname'),
        },
    );
    if( my $message = session('flash') ) {
        $global{tokens}->{flash}      = $message;
        $global{tokens}->{flash_span} = session('flash_span');
        session flash      => undef;
        session flash_span => undef;
    }
};