'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?

2 Answers 2


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.

  • Cool. Thank you :)
    – KSPR
    Commented Oct 12, 2014 at 14:06
  • 2
    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
    Commented Apr 8, 2015 at 8:26

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 }}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.