Static files deployment

1 Instructions

To perform the necessary actions via SSH, navigate to the Magento root directory and execute the following commands:

1.1 Remove old data
rm -rf var/view_preprocessed/code/*
rm -rf var/view_preprocessed/metadata/*
rm -rf pub/static/adminhtml/*
rm -rf pub/static/frontend/*
rm -rf pub/static/_cache/*
1.2 Deploy static content
php bin/magento setup:static-content:deploy -f en_US -t Magento/backend
php bin/magento setup:static-content:deploy -f en_US -t Habi/flexmarket_child

Note

  • Replace en_US with your specific language code (e.g., fr_FR).
  • Replace Habi/flexmarket_child with your active theme code (e.g., Habi/flexmarket_custom).
  • You can identify the theme code and language code by viewing the page source.

To deploy static content for all themes, remove the -t parameter from the command. For multiple languages, simply list the desired language codes, as shown below:

php bin/magento setup:static-content:deploy -f en_US fr_FR es_CO
2 Tip for quick deployment

You can automate the static content deployment process by creating a shell script (e.g., deploy-theme.sh) and placing it in your Magento root directory.

Inside the file, include the following commands:

rm -rf var/view_preprocessed/code/*
rm -rf var/view_preprocessed/metadata/*
rm -rf pub/static/adminhtml/*
rm -rf pub/static/frontend/*
rm -rf pub/static/_cache/*
php bin/magento setup:static-content:deploy -f en_US -t Magento/backend
php bin/magento setup:static-content:deploy -f en_US -t Habi/flexmarket_child
php bin/magento cache:flush

Note: Make sure to update en_US and Habi/flexmarket_child according to your language and theme.

Each time you need to deploy static content, simply execute:

sh deploy-theme.sh

This approach saves time and ensures consistency when deploying static assets.