I use the @web alias in the configuration of the base URLs of the sites (following Craft 3 documentation). 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.

  • The "Craft 3 documentation" link is no longer active. Commented Jan 28, 2020 at 4:21
  • 1
    Thank you @DavidRhoden, link updated.
    – Romain P.
    Commented Jan 28, 2020 at 9:29

1 Answer 1


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

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.