<p>So luckily for us, Brandon recently added the <code>alias()</code> Twig function. It should show up in Craft CMS 3 RC7. You can see the discussion about it here: <a href="https://github.com/craftcms/cms/issues/2327" rel="nofollow noreferrer">https://github.com/craftcms/cms/issues/2327</a></p>

CC BY-SA 3.0
2018-01-23T13:00:03.757Z
2018-01-23T13:00:03.757Z
andrew.welch
<p>I use the <code>@web</code> alias in the configuration of the base URLs of the sites (following <a href="https://docs.craftcms.com/v3/config/#aliases" rel="nofollow noreferrer">Craft 3 documentation</a>). The <code>@web</code> alias allows a shortcut  to the URL of the folder that contains the <code>index.php</code> file loaded for the request.</p>

<p>However, when I loop through <code>craft.app.sites.getAllSites</code> using Twig, the value of baseUrl still prints <code>@web</code> in the URL, instead of transform it in its original URL.</p>

<p>As a workaround, I could get the original URL using <code>{{ craft.app.sites.currentSite.baseUrl ~ site.uri | replace({ '@web': '' }) }}</code>. But this seems a very dirty solution that will probably not always work.</p>

CC BY-SA 4.0
2020-01-28T04:21:21.850Z
The "Craft 3 documentation" link is no longer active.
David Rhoden
CC BY-SA 4.0
2020-01-28T09:29:05.000Z
Thank you @DavidRhoden, link updated.
Romain P.
<templating><craft3><multi-site>
Craft 3: with Base URL of site set up using @web alias, how to display the original URL in Twig templates?
# Craft 3: with Base URL of site set up using @web alias, how to display the original URL in Twig templates?

(Asked by: username_0 on 2018-01-23)

I use the `@web` alias in the configuration of the base URLs of the sites (following [Craft 3 documentation](https://docs.craftcms.com/v3/config/#aliases)). The `@web` alias allows a shortcut to the URL of the folder that contains the `index.php` file loaded for the request.

However, when I loop through `craft.app.sites.getAllSites` using Twig, the value of baseUrl still prints `@web` in the URL, instead of transform it in its original URL.

As a workaround, I could get the original URL using `{{ craft.app.sites.currentSite.baseUrl ~ site.uri | replace({ '@web': '' }) }}`. But this seems a very dirty solution that will probably not always work.

**Tags:** templating, craft3, multi-site
> **Comments:**
> **username_1**: The "Craft 3 documentation" link is no longer active.  
> **username_0**: Thank you @DavidRhoden, link updated.  

---

## 1 answers

### Answer by username_2 on 2018-01-23. Score: 4 | Accepted answer

So luckily for us, Brandon recently added the `alias()` Twig function. It should show up in Craft CMS 3 RC7. You can see the discussion about it here: <https://github.com/craftcms/cms/issues/2327>


---

