0

I'm trying to do a multilingual site e.g. /nl /de though when browsing to these URL's all is working apart from the static images hosted in .../nl/web/img it seems to be looking for URL's still within the base URL.

Is there a way to setup the site so that it properly fetches shared static assets for multilingual sites? Or what is the best way of achieving this?

Thanks

1
  • Please include screenshots of your file system and asset volume configuration, as well as the Settings -> Websites settings and any relevant .env variables and the physical directory structure.
    – MoritzLost
    Aug 3 at 10:51

2 Answers 2

1

At my site I use the same top level domain name. So it's always /assets/img based on the root. So domainname.tld/assets/imgand not domainname.tld/de/assets/img

Or go away from hosting your assets locally on your server. I use Amazon S3 for most of my side projects for hosting images. And then I don't care what my domain structure is for assets.

New contributor
Thomas Sausen is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
2
  • And how does your templating look to get an image at that root domain?
    – JMKelley
    Aug 5 at 14:36
  • Ok, in my current setup it's not always the root. Sorry for that. First I had the problem with the CSS, because I loaded the CSS with just something like ../assets/css/main.css I changed this to {% css "/assets/css/main.css" %}. I load my favicons in my <head>with something like {{ url('assets/images/favicon/favicon-32x32.png') }} This way, my Twig will output: https://domainname.io/de/assets/images/favicon/favicon-32x32.png at my german site and https://domainname.io/assets/images/favicon/favicon-32x32.pngat the english site. Aug 5 at 21:20
0

If the sites all share the same top level domain name, I would use site-root relative paths for your asset base URLs (i.e., ones that start with a forward slash: /img), and similar for your asset base path: /server/path/to/img, so that they all point to the same directory. If the sites use separate top level domain names, I would create symlinks on the server to achieve the same thing (pointing them all to a canonical directory on the primary site so that I can still use root-relative paths).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.