What is Magento 2 Static Content Deploy and How to do it?

In this quick tutorial, we will learn what is Magento 2 Static Content and how to deploy Magento 2 Static Content.

First, we learn what is Static View.

What is Magento 2 Static View?

Magento Static View is made of two terms.

Static: It means the file is the same for every reload of the webpage. Static files and pages can be cached—for example, images, text etc.

View: The presentation layer.

The static view files deployment command enables you to write static files to the Magento file system when the Magento software is set for production mode.

You will find the Static View files in the <magento_root>/pub/static directory, and some are cached in the <magento_root>/var/view_preprocessed directory as well.

Magento Modes

Magento platform comes with three modes.

  1. Default: The mode when you install the Magento. Basic configurations.
  2. Developer: The mode where the developer works. The caching is disabled, and the changes can be viewed quickly in this mode. It is also known as Maintenance mode.
  3. Production: The mode for the live store. With all the speed and performance optimizations, caching enabled mode to boost the store speed.

Magento modes affect the deployment of Static View files.

  • Default and Developer Mode: Magento generates the Static View on-demand. However, the rest are cached in a file for quick access.
  • Production Mode: Static files are not generated or cached.

You can find the mode of your Magento store by quickly running the following commands in the root directory:

php bin/magento deploy:mode:show

You have to write static view files manually to the file system of your Magento 2 store by using the CLI command. After running the CLI command, you can restrict permissions to limit vulnerabilities and prevent malicious overwriting of files.

Now you know what is Static View, where the files are located, and Modes that affect them; let’s see how to deploy Static View.

Magento 2 Deploy Static Content Using CLI

Follow the steps to deploy static view files:

  1. Log in to the Magento server as the file system owner.
  2. Delete the contents of <magento_root>/pub/static, except for the .htaccess file. Do not delete this file.
  3. Run the code to deploy static view files:

php bin/magento setup:static-content:deploy

The complete code looks like this:

bin/magento setup:static-content:deploy [<languages>] [-t|--theme[="<theme>"]] [--exclude-theme[="<theme>"]] [-l|--language[="<language>"]] [--exclude-language[="<language>"]] [-a|--area[="<area>"]] [--exclude-area[="<area>"]] [-j|--jobs[="<number>"]] [--no-javascript] [--no-css] [--no-less] [--no-images] [--no-fonts] [--no-html] [--no-misc] [--no-html-minify] [--no-parent] [-f|--force]

The following table explains this command’s parameters and values.

Magento 2 Deploy Static Content View Image

See More.

Magento 2 Static Content Deploy in Breeze Platform

If you use Breeze to manage your Magento store, you can deploy static content from the platform itself.

  1. Follow the steps to clear all website cache.
  2. Login to your Breeze platform
  3. Select the Company you like to work on
  4. Click on the ‘Sites’ to open the site list
  5. Open the ‘Website’
  6. Go to the ‘Magento’ Section
  7. Deploy the Static Content
Magento Static Content Breeze

You can also view the log to see the static content history of the store.

Deploy static view files without installing Magento

If you want to build processes and do not want to risk the sensitive production machine, you must run the deployment in a different, non-production environment.

Follow the steps to do this:

  1. Export the configuration from the production system:
bin/Magento app:config:dump
  1. Copy the exported files to the non-production code base.
  2. Run bin/Magento setup:static-content:deploy.

Final Words

That’s it.

In this tutorial, we learn to deploy static content on Magento 2. If you encounter an issue, please leave it in the comments.

Latest Magento Tips, Guides, & News

Stay updated with new stuff in the Magento ecosystem including exclusive deals, how-to articles, new plugins, and more. 100% Magento Goodness, a promise!

Leave a Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Scroll to Top

🎉 CYBER MONDAY SAVINGS 🎉

75% OFF on
ALL PLANS

Receive the coupon as soon as you
submit the email address. 🚀