Answers.Body: <p>At my site I use the same top level domain name. So it's always <code>/assets/img</code> based on the root. So <code>domainname.tld/assets/img</code>and not <code>domainname.tld/de/assets/img</code></p>
  <p>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.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-08-05T14:36:49.260Z
Answers.Text: And how does your templating look to get an image at that root domain?
Answers.UserDisplayName: JMKelley
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-08-05T21:20:28.917Z
Answers.Text: 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.png`at the english site.
Answers.UserDisplayName: Thomas Sausen
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-08-05T10:42:36.263Z
Answers.LastActivityDate: 2022-08-05T10:42:36.263Z
Answers.UserDisplayName: Thomas Sausen
Answers.Body: <p>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: <code>/img</code>), and similar for your asset base path: <code>/server/path/to/img</code>, 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).</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-08-03T11:15:36.870Z
Answers.LastActivityDate: 2022-08-03T11:15:36.870Z
Answers.UserDisplayName: James Smith
Body: <p>I'm trying to do a multilingual site e.g. <code>/nl</code> <code>/de</code> though when browsing to these URL's all is working apart from the static images hosted in <code>.../nl/web/img</code> it seems to be looking for URL's still within the base URL.</p>
  <p>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?</p>
  <p>Thanks</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2022-08-03T10:51:29.037Z
Comments.Text: 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.
Comments.UserDisplayName: MoritzLost
Tags: <localization><craft4>
Title: Shared Static Assets for Multilingual
ThreadText: # Shared Static Assets for Multilingual
  
  (Asked by: username_0 on 2022-08-03)
  
  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
  
  **Tags:** localization, craft4
  
  > **Comments:**
  > **username_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.  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_2 on 2022-08-05. Score: 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/img`and 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.
  
  > **Comments:**
  > **username_0**: And how does your templating look to get an image at that root domain?  
  > **username_2**: 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.png`at the english site.  
  
  ---
  
  ### Answer by username_3 on 2022-08-03. Score: 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).
  
  
  ---
  
  