<p>If you want to use envVars as you would in the control panel i.e. <code>{baseUrl}</code> but, in your templates, then check out the <a href="https://github.com/lindseydiloreto/craft-filterenvvar/" rel="nofollow">Filter Environment Variables</a> plugin.</p>

<blockquote>
  <p>Just apply the <code>envvar</code> filter to your Twig variable:</p>

<pre><code>{% set myVar = '{baseUrl}/contact-us' %}

{{ myVar | envvar }}
</code></pre>
</blockquote>

CC BY-SA 3.0
2015-04-07T06:44:00.467Z
2015-04-07T06:44:00.467Z
Natetronn
<p>You can get to any of your config variables (including custom ones) like this:</p>



<pre class="lang-twig prettyprint-override"><code>{{ craft.config.xyz }}
</code></pre>

<p>The environmentVariables array is no different:</p>

<pre class="lang-twig prettyprint-override"><code>{{ craft.config.environmentVariables.baseUrl }}
</code></pre>

<p>See the <a href="http://buildwithcraft.com/docs/templating/craft.config">craft.config</a> documentation.</p>

CC BY-SA 3.0
2015-04-08T08:26:48.463Z
Also, if you wanted to use the shorter version of `{{ baseUrl }}`, you could also add `{% set baseUrl = craft.config.environmentVariables.baseUrl %}` at the top of your template.
Alex Roper
CC BY-SA 3.0
2014-10-12T14:06:17.707Z
Cool. Thank you :)
KSPR
CC BY-SA 3.0
2014-10-11T11:32:45.307Z
2014-10-11T16:02:38.800Z
2014-10-11T16:02:38.800Z
André Elvan
<pre><code>'dev' =&gt; array(
        'siteUrl' =&gt; array(
            'de_ch' =&gt; 'http://blabla.dev/',
            'en' =&gt; 'http://blabla.dev/en/',
        ),
        'environmentVariables' =&gt; array(
            'basePath' =&gt; 'path',
            'baseUrl' =&gt; 'http://url-without-locale-segment.dev/',
        )
    ),
</code></pre>

<p>I set a <code>baseUrl</code> inside <code>environmentVariables</code> to be able to grab the url without a locale. But when I enter <code>{{ baseUrl }}</code> in the template it returns an error:</p>

<blockquote>
  <p>Variable "baseUrl" does not exist</p>
</blockquote>

<p>How do I have to write this?</p>

<config><multi-environment>
grab 'environmentVariables' with a tag
# grab 'environmentVariables' with a tag

(Asked by: username_0 on 2014-10-11)

'dev' => array(
        'siteUrl' => array(
            'de_ch' => 'http://blabla.dev/',
            'en' => 'http://blabla.dev/en/',
        ),
        'environmentVariables' => array(
            'basePath' => 'path',
            'baseUrl' => 'http://url-without-locale-segment.dev/',
        )
    ),

I set a baseUrl inside environmentVariables to be able to grab the url without a locale. But when I enter {{ baseUrl }} in the template it returns an error:

Variable "baseUrl" does not exist

How do I have to write this?

**Tags:** config, multi-environment

---

## 2 answers

### Answer by username_2 on 2014-10-11. Score: 19 | Accepted answer

You can get to any of your config variables (including custom ones) like this:
{{ craft.config.xyz }}

The environmentVariables array is no different:
{{ craft.config.environmentVariables.baseUrl }}

See the craft.config documentation.

> **Comments:**
> **username_0**: Cool. Thank you :)  
> **username_3**: Also, if you wanted to use the shorter version of `{{ baseUrl }}`, you could also add `{% set baseUrl = craft.config.environmentVariables.baseUrl %}` at the top of your template.  

---

### Answer by username_1 on 2015-04-07. Score: 3

If you want to use envVars as you would in the control panel i.e. {baseUrl} but, in your templates, then check out the Filter Environment Variables plugin.

Just apply the envvar filter to your Twig variable:
{% set myVar = '{baseUrl}/contact-us' %}

{{ myVar | envvar }}


---

