Magento2 Regenerate full static content

You can regenerate your static content by running the following command

php bin/magento setup:static-content:deploy

This is the command you'd run before deploying to production mode. If you're running in default or developer mode, those files should be generating for your automatically. My guess is you accidentally removed a folder Magento expects to be there -- running setup:static-content:deploy may restore that folder, or may result in an explicit error about the missing folders. If it's the later, the error should (hopefully!) provide enough information to rebuild the missing directories. You may want to run the command in verbose mode

php bin/magento -vvv setup:static-content:deploy

This will tell the bin/magento command to output the actual exception if there's an error.


What caused this is that when you removed the pub/static folder itself, you removed an .htaccess file that is necessary for regenerating content while in production mode. Without that file, no assets will be automatically regenerated.

If this ever happens again, you could copy that file from another Magento 2 instance (if you have another one setup) or try to restore the file by copying the .htaccess from Magento's GitHub: https://github.com/magento/magento2/blob/develop/pub/static/.htaccess

To prevent this from happening, only empty the contents of a folder under the pub/static directory, such as frontend or adminhtml.


You just need to run this command to generate static content:

php bin/magento setup:static-content:deploy

Make sure the owner of pub static is same as your Magento owner.

Make sure you have the required .htaccess file in your folder.