<p>Try using <code>{{ currentSite.baseUrl }}</code></p>

<p>I had the same issue when I started using environment variables instead of <code>@web</code> for my sites. I've found the above works for all cases.</p>

CC BY-SA 4.0
2019-07-04T00:38:01.303Z
2019-07-04T00:38:01.303Z
MalTek
<p>I am using <code>{{ siteUrl }}</code> for absolute links. It works 95% of the time. But if I press the reload button multiple times in a few seconds (overloading or something) my links look like this: </p>

<pre><code>href="$DEFAULT_SITE_URL/css/order.css" 
</code></pre>

<p>instead of </p>

<pre><code>href="http://localhost/craft/web/css/order.css"
</code></pre>

<p>other Twig commands are working fine at the same time. What's happening?</p>

<templating><siteurl>
{{siteUrl}} not working on load
# {{siteUrl}} not working on load

(Asked by: username_0 on 2019-07-02)

I am using {{ siteUrl }} for absolute links. It works 95% of the time. But if I press the reload button multiple times in a few seconds (overloading or something) my links look like this: 
href="$DEFAULT_SITE_URL/css/order.css" 

instead of 
href="http://localhost/craft/web/css/order.css"

other Twig commands are working fine at the same time. What's happening?

**Tags:** templating, siteurl


---

## 1 answers

### Answer by username_1 on 2019-07-04. Score: 2 | Accepted answer

Try using `{{ currentSite.baseUrl }}`

I had the same issue when I started using environment variables instead of `@web` for my sites. I've found the above works for all cases.


---

