Deploying static content in Magento 2 is performed via the command line. When running your Magento store in production mode, eventually you will need to run this command.
As we know in production mode, static files are not generated or cached, therefore they must be written to the Magento file system manually.
The below command will help you achieve this.
/path/to/php bin/magento setup:static-content:deploy
As of Magento version 2.1, there are more options you can pass in as arguments to this command.
/path/to/php bin/magento setup:static-content:deploy [<list of languages>] [-t|--theme[="
Running the command without any arguments will generate static content to the following areas, languages and themes.
/path/to/php bin/magento setup:static-content:deploy Requested languages: en_US Areas: frontend, adminhtml Themes: Magento/blank, Magento/luma, Magento/backend
Deploying static content can take up to a few minutes to run, and it is highly likely that you will only want to deploy content to your specific theme, and not
Magento/backend for example.
Using the argument list above, if you wanted to deploy static content for the
Magento/luma theme only in
en_US, you would run the following:
/path/to/php bin/magento setup:static-content:deploy -a frontend -t Magento/luma
-a is the area and
-t is the theme.
en_US is the default language Magento uses.
Should you want to find out the expected output without deploying static content, you can pass in the dry run argument.
/path/to/php bin/magento setup:static-content:deploy -d
Magento/backend by default runs in
en_US, so you’ll want to ensure that you deploy static content for this theme passing in the en_US argument.
For your frontend theme files, you should deploy the static content using the locale you set in the admin under Stores -> Configuration -> General.
So for example if the locale was set to
French (France), your theme’s static content should be deployed using the
fr_FR ISO-636 language code.
Note: This article is based on Magento CE version 2.1.