2

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 ?

1
  • 2
    you can also add a locale variable with the static-content command, e.g. 'php bin/magento setup:static-content:deploy en_US en_AU' maybe that will solve your problem
    – juhanix
    Mar 21, 2018 at 15:41

3 Answers 3

3

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

1
  • 1
    Very nice you mentioned static-content by default deploys en_US. I was wondering where did this en_US folder comes from. Mar 22, 2018 at 7:30
2
  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
-2

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)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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