v2-hub
v2-hub copied to clipboard
{{ theme:asset }} always outputs absolute urls
Describe the bug
According to the docs, the {{ asset }}
tag should output relative urls by default. However, it outputs full urls.
To Reproduce
- Add the following tag in your template:
{{ theme:asset src="assets/app.js" }}
- Check the source code
You'll see that the asset is referenced absolute: https://mydomain.com/themes/mytheme/assets/app.js
Expected behavior
The url to the asset should be relative (/themes/mytheme/assets/app.js
) and only be absolute if the parameter absolute
is set to true
.
Solution
Remove the call to URL::prependSiteUrl
in Statamic\Addons\Theme\ThemeTags::themeUrl()
.
Environment details (please complete the following information):
- Statamic Version
2.11.5
It only appends the site_url as defined in your system locales
setting. Do you have the full domain in there?
Hi @jackmcdade
Yep, I have the full domain in there. I assumed that this would be the expected setup because the docs about localization use full urls: https://docs.statamic.com/localization#locales
Can I use relative urls as well?
Cheers