Zend certified PHP/Magento developer

Override the canonical URL in custom layout handler

I’m attempting to override the canonical URL for a custom handler. I tried adding the following code via XML, but instead of overriding the default canonical URL, I now have both the default and the one I set. Does anyone have an idea on how to achieve this? Thank you.

<head>
    <link rel="canonical" src="https://mystore/test" src_type="url" />
</head>