Multi-language site url without language code

Hi,

I have some global images that I use throughout the site. I want the url to be the same even when switching between languages.

<img src="<?= $site->url() ?>/assets/media/content/image.jpg">

When I switch language, the above results in a broken image:

<img src="example.com/fr/assets/media/content/image.jpg">

With some testing I noticed that $site->url(’’) would fix the problem, is this the correct way to do it?

Final solution:

<img src="<?= $site->url('') ?>/assets/media/content/image.jpg">

try

kirby()->urls()->assets().'/media/content/image.jpg'

2 Likes

Thanks that worked!

1 Like