<p>You need to set it without an <code>@</code></p>

<pre class="lang-PHP prettyprint-override"><code>'*' =&gt; [
    'aliases' =&gt; [
        'myNewAlias' =&gt; getenv('SITE_URL_DE')
     ]
]
</code></pre>

<p>Then you can do</p>

<pre class="lang-TWIG prettyprint-override"><code>{{ alias('@myNewAlias') }}
</code></pre>

<p>or in PHP</p>

<pre class="lang-PHP prettyprint-override"><code>Craft::getAlias('@myNewAlias');
</code></pre>

CC BY-SA 4.0
2019-03-05T08:34:11.347Z
2019-03-05T08:34:11.347Z
Robin Schambach
<p>I'm not sure if I understand the alias concept entirely</p>

<p>So I want to create an alias.</p>

<p>I write a variable into my <code>.env</code> File: </p>

<pre><code>SITE_URL_DE="http://hello.local"
</code></pre>

<p>Then I put it into my <code>general.php</code> File:</p>

<pre><code>'*' =&gt; [
    //other settings as well here
    'aliases' =&gt; [
      '@myNewAlias' =&gt; getenv('SITE_URL_DE'),
    ],
  ],
</code></pre>

<p>Now I want to print it in my template:</p>

<pre><code>{{ alias('@myNewAlias') }}
</code></pre>

<p>This results in: </p>

<blockquote>
  <p>Invalid path alias: @myNewAlias</p>
</blockquote>

<p>But why?</p>

<config><siteurl><alias>
Invalid path alias
# Invalid path alias

(Asked by: username_0 on 2019-03-05)

I'm not sure if I understand the alias concept entirely
So I want to create an alias.
I write a variable into my .env File: 
SITE_URL_DE="http://hello.local"

Then I put it into my general.php File:
'*' => [
    //other settings as well here
    'aliases' => [
      '@myNewAlias' => getenv('SITE_URL_DE'),
    ],
  ],

Now I want to print it in my template:
{{ alias('@myNewAlias') }}

This results in: 

Invalid path alias: @myNewAlias

But why?

**Tags:** config, siteurl, alias


---

## 1 answers

### Answer by username_1 on 2019-03-05. Score: 2 | Accepted answer

You need to set it without an @
'*' => [
    'aliases' => [
        'myNewAlias' => getenv('SITE_URL_DE')
     ]
]

Then you can do
{{ alias('@myNewAlias') }}

or in PHP
Craft::getAlias('@myNewAlias');


---

