New Free Preview

Generate and deploy static content files using CLI in Magento

Video Lesson: Generate and deploy static content files using CLI in Magento

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:

  1. Collecting static files from your theme and modules

  2. Processing them (minifies CSS/JS, compiles LESS to CSS, merges files when configured)

  3. Organizing them by locale, theme, and file type

  4. 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 adminhtml

  • l or --language: Generate files only for specific languages

  • t 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.