<link rel="canonical" href="{{ (href is defined) ? href : palmtree_canonical_url() }}">

<link rel="canonical" href="{{ (href is not empty) ? href : palmtree_canonical_url() }}">

Check for href being not empty instead of null
Check for href being not empty instead of null
