Outputting siteUrl consumes next closing tag
Try to set the siteUrl in config/general.php like so.

return array(
    '*' =&gt; array(
    ),
    'localhost' =&gt; array(
        'siteUrl' =&gt; 'http://localhost:3001/',
    ),
);


And then apply your replace filter.

&lt;span&gt;{{ siteUrl|replace({'localhost:3001': 'mysite.com'}) }}&lt;/span&gt;