Answers.Body: <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>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2018-01-23T13:00:03.757Z
Answers.LastActivityDate: 2018-01-23T13:00:03.757Z
Answers.UserDisplayName: andrew.welch
Body: <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>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-01-28T04:21:21.850Z
Comments.Text: The "Craft 3 documentation" link is no longer active.
Comments.UserDisplayName: David Rhoden
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-01-28T09:29:05.000Z
Comments.Text: Thank you @DavidRhoden, link updated.
Comments.UserDisplayName: Romain P.
Tags: <templating><craft3><multi-site>
Title: Craft 3: with Base URL of site set up using @web alias, how to display the original URL in Twig templates?
ThreadText: # 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 @username_1, 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>
  
  
  ---
  
  