Answers.Body: <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>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-03-18T11:16:56.290Z
Answers.LastActivityDate: 2015-03-18T11:16:56.290Z
Answers.UserDisplayName: carlcs
Body: <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>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-03-18T11:06:46.603Z
Comments.Text: Do you set it in config/general.php and why do you omit the "http:" part?
Comments.UserDisplayName: carlcs
Tags: <templating><siteurl><debugging>
Title: Outputting siteUrl consumes next closing tag
ThreadText: # 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:
  
  ```
  <span>{{ siteUrl }}</span>
  
  ```
  
  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.
  
  ```
  <span>{{ siteUrl|replace({'localhost:3001': 'mysite.com'}) }}</span>
  
  ```
  
  
  ---
  
  