Multi language page problem to access assets from javascript


I set up a site with de/en language, with en as default and language detection similar to the getting started doc.
On the site I need to swap an image on every load of the page with Javascript, which works fine in the default language, since it doesn´t add anything to the path, but as soon as I change the language it adds a /de and it doesnt work anymore. I can handle this is in Javascript (which is currently just one line), or is there a smarter way to do this in the config or elsewhere in kirby?
Many Thanks, C.

I usually keep the URL-parameter for the default language also in the URL.

Thanks, I added it and interestingly it works in both languages for the landing page, until I navigate to a subpage in both languages.

You could pass the URL as a data attribute you can call in your JS.

1 Like