Is this a bug or is this me ? (I'm a new to craft)
When using the @web alias directly within an attribute in a Twig template, the alias doesn't seem to be resolved to its corresponding URL. Instead, the literal string @web is rendered in the final output.
Steps to Reproduce:
- Define the @web alias in general.php:
->aliases([
'@web' => 'http://craftsite.ddev.site/'
])
2.Use the alias directly in a Twig template's attribute:
<link rel="stylesheet" href="@web/css/app.css">
- View the rendered HTML. The output is:
<link rel="stylesheet" href="@web/css/app.css">
The expected output should be:
<link rel="stylesheet" href="http://craftbites.ddev.site/css/app.css">
Workaround:
Resolving the alias to a variable first and then using that variable in the attribute resolves the issue:
{% set baseUrl = alias('@web') %}
<link rel="stylesheet" href="{{ baseUrl }}/css/app.css">
Environment:
- Craft version: 4.5
- PHP version: 8.1