Yes, looks like that’s the only way possible as you might need to support both values of canonifyURLs for your theme.
Also, I cannot find it, but there was an issue with link canonification not working as expected within CSS.
While looking for it, I came across this, so now this whole thread feels like deja vu: