<p>Try to set the <code>siteUrl</code> in config/general.php like so.</p>

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

<p>And then apply your replace filter.</p>

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

CC BY-SA 3.0
2015-03-18T11:16:56.290Z
2015-03-18T11:16:56.290Z
carlcs
<p>I'm running Craft Pro 2.3.2640.</p>

<p>Here is the code:</p>

<pre><code>&lt;span&gt;{{ siteUrl }}&lt;/span&gt;
</code></pre>

<p>Here is the output:</p>

<pre><code>//localhost:3001/%3C/span%3E
</code></pre>

<p>The opening tag stays intact.</p>

<p>I am also struggling to use this variable with functions like "replace" when I need to parse the referral url.</p>

CC BY-SA 3.0
2015-03-18T11:06:46.603Z
Do you set it in config/general.php and why do you omit the "http:" part?
carlcs
<templating><siteurl><debugging>
Outputting siteUrl consumes next closing tag
# Outputting siteUrl consumes next closing tag

(Asked by: username_0 on 2015-03-18)

I'm running Craft Pro 2.3.2640.
Here is the code:
{{ siteUrl }}

Here is the output:
//localhost:3001/%3C/span%3E

The opening tag stays intact.
I am also struggling to use this variable with functions like "replace" when I need to parse the referral url.

**Tags:** templating, siteurl, debugging
> **Comments:**
> **username_1**: Do you set it in config/general.php and why do you omit the "http:" part?  

---

## 1 answers

### Answer by username_1 on 2015-03-18. Score: 2 | Accepted answer

Try to set the siteUrl in config/general.php like so.
return array(
    '*' => array(
    ),
    'localhost' => array(
        'siteUrl' => 'http://localhost:3001/',
    ),
);

And then apply your replace filter.
{{ siteUrl|replace({'localhost:3001': 'mysite.com'}) }}


---

