Generate and deploy static content files using CLI in Magento
Generate and deploy static content files using CLI in Magento
Video Lesson: Generate and deploy static content files using CLI in Magento
Learn how to generate and deploy Magento static content files using the CLI setup:static-content:deploy command for optimized store performance.
Published 1 week ago
Share with colleagues:
Lesson Content
Static content files are non-PHP files that don't need to be processed by the server each time they're requested.
These static files include:
CSS files
JavaScript files
Images
Fonts
HTML files (when not dynamically generated)
The setup:static-content:deploy
command deploys these static content files, which includes:
Collecting static files from your theme and modules
Processing them (minifies CSS/JS, compiles LESS to CSS, merges files when configured)
Organizing them by locale, theme, and file type
Deploying them to the
pub/static
directory for direct serving
This process is essential for performance — without it, Magento would need to dynamically generate these files on each page request, which would significantly slow down your store.
You can also deploy files for a specific language, or use one of the other available flags:
bin/magento setup:static-content:deploy [--language en_US ...]
Here are the key command flags to know:
f
or--force
: Deploy files in any mode, even default and developer (which require this flag)s
or--strategy
: Change the deployment strategy (standard, quick, compact)a
or--area
: Specify areas like frontend or adminhtmll
or--language
: Generate files only for specific languagest
or--theme
: Deploy for specific themes--no-parent
: Skip generation of parent themes, which can significantly improve the speed of deployments
You can check out the docs or pass in the --help
flag to get the full list of available flags.
Remember: This command should not typically be executed in developer mode, as static assets are compiled automatically. In production mode, this command must be run after any code changes to refresh the static files that are served by Magento.