Question

I have enabled Production mode, and when I run setup:static-content:deploy, it creates two folders - en_AU and en_US.

In pub/static/frontend/mytheme/, en_US folder has all nessesary files generated, and en_AU folder has only one .js file generated.

When I refresh my front-end, I can see all files including css and js are loaded from en_AU folder, but since this folder is emtpy, so my front-end is not displaying correctly. Then I need to manually copy everything from en_US to en_AU to make front-end working.

Why does system creates two folders with one has all contents, and another empty, but front-end is reading from the empty folder.

How can I fixed this issue ?

Was it helpful?

Solution

Make sure you've selected English (United States) in your locale settings: Stores > Configuration > General > Locale Options

setup:static-content:deploy by default deploys en_US

If you'd like to use en_AU, change your Locale Settings in the admin to English (Australia) and run setup:static-content:deploy en_AU

OTHER TIPS

  1. You have to set the right language for your website admin > Stores > Configuration > Locale, if you inspect the dropdown options, you will see all the code_ISO and the language name, according to your post you will select :

    English (Australia) :: <option value="en_AU">anglais (Australie)</option>

  2. You have to clean the content folder of : pub/static, var/view_preprocessed, var/cache

  3. Now deploy the static-content, you can target only the locale language like this:

    • php bin/magento setup:static-content:deploy en_AU

Bonus: You can also deploy the static-content for the current theme only like this:

  • php bin/magento setup:static-content:deploy --theme Theme/name en_AU

You don't have configured properly nginx or you remove .htaccess from pub/static. It need to have:

<IfModule mod_rewrite.c>
    RewriteEngine On

    # Remove signature of the static files that is used to overcome the browser cache
    RewriteRule ^version.+?/(.+)$ $1 [L]

    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-l

    RewriteRule .* ../static.php?resource=$0 [L]
</IfModule>

This code ensure that files in pub/static are generated properly.

If there isn't even symlink then you get broken frontend. Make sure to do properly deploy as mentioned above and of course check if write permission are correctly set (same as process php running magento)

Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top