{"id":385,"date":"2019-04-25T04:35:51","date_gmt":"2019-04-25T04:35:51","guid":{"rendered":"https:\/\/meetanshi.com\/blog\/2019\/04\/25\/magento-2-static-content-deploy\/"},"modified":"2025-07-23T10:05:56","modified_gmt":"2025-07-23T04:35:56","slug":"magento-2-static-content-deploy","status":"publish","type":"post","link":"https:\/\/meetanshi.com\/blog\/magento-2-static-content-deploy\/","title":{"rendered":"Magento 2 Static Content Deploy &#8211; A Complete Guide"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">The tutorial includes the stepwise method to <i>deploy static content in Magento 2<\/i>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Trace the static view files in the static directory of your Magento 2 store at your<strong> Magento install dir&gt;\/pub\/static<\/strong>. Some files are also cached in the <strong>Magento install dir&gt;\/var\/view_preprocessed<\/strong>&nbsp;directory.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">One needs to write static view files manually to the file system of the Magento 2 store with CLI command. After running the CLI command,&nbsp;restrict permissions to limit vulnerabilities as well as for the prevention of malicious overwriting of files.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><i><strong>Note: <\/strong>It is required to clean the old files of CSS, Javascript, layouts, etc to make sure that static files run smoothly on enabling a new module in the developer mode.<\/i><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Clean the generated static view files with the below steps:<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Manual method:<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Clear all the files under <strong>pub\/static directory<\/strong>&nbsp;except <strong>.htaccess<\/strong>&nbsp;file with the below command:<br>find .&nbsp;-depth -name .htaccess -prune -o -delete<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Automated method:<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Login to Admin panel<\/li>\n\n\n\n<li>Go to <strong>Systems &gt; Tools &gt; Cache Management<\/strong><\/li>\n\n\n\n<li>Click the <strong>Flush Static Files Cache<\/strong>.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Method for Magento 2 Static Content Deploy via Command Line:<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Navigate to Magento admin root folder. Show usages:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>php bin\/magento setup:static-content:deploy -f<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Usage:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>setup:static-content:deploy &#91;options] &#91;--] &#91;&lt;languages&gt;]...<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Arguments:<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th><strong>Options<\/strong><\/th><th><strong>Description<\/strong><\/th><th><strong>Description<\/strong><\/th><\/tr><\/thead><tbody><tr><td>-f<\/td><td>&nbsp;<em>&#8212;<\/em>force<\/td><td>Deploy files in any mode<\/td><\/tr><tr><td>-s<\/td><td>&nbsp;&#8211;strategy[=STRATEGY]<\/td><td>Deploy files using specified strategy.<\/td><\/tr><tr><td rowspan=\"2\">-a<\/td><td>&nbsp;&#8211;area<\/td><td>Generate files only for the specified areas. [default: [&#8220;all&#8221;]] (multiple values allowed)<\/td><\/tr><tr><td>&#8211;exclude-area[=EXCLUDE-AREA]<\/td><td>Do not generate files for the specified areas. [default: [&#8220;none&#8221;]] (multiple values allowed)<\/td><\/tr><tr><td rowspan=\"2\">-t<\/td><td>&#8211;theme[=THEME]<\/td><td>Generate static view files for only the specified themes. [default: [&#8220;all&#8221;]] (multiple values allowed)<\/td><\/tr><tr><td>&#8211;exclude-theme[=EXCLUDE-THEME]<\/td><td>Do not generate files for the specified themes. [default: [&#8220;none&#8221;]] (multiple values allowed)<\/td><\/tr><tr><td rowspan=\"2\">-l<\/td><td>&#8211;language[=LANGUAGE]<\/td><td>Generate files only for the specified languages. [default: [&#8220;all&#8221;]] (multiple values allowed)<\/td><\/tr><tr><td>&#8211;exclude-language[=EXCLUDE-LANGUAGE]<\/td><td>Do not generate files for the specified languages. [default: [&#8220;none&#8221;]] (multiple values allowed)<\/td><\/tr><tr><td rowspan=\"12\">-j\n\n&nbsp;\n\n&nbsp;<\/td><td>&#8211;jobs[=JOBS]<\/td><td>Enable parallel processing using the specified number of jobs. [default: 0]<\/td><\/tr><tr><td>&#8211;symlink-locale<\/td><td>Create symlinks for the files of those locales, which are passed for deployment, but have no customizations.<\/td><\/tr><tr><td>&#8211;content-version=CONTENT-VERSION<\/td><td>Custom version of static content can be used if running deployment on multiple nodes to ensure that static content version is identical and caching works properly.<\/td><\/tr><tr><td>&#8211;refresh-content-version-only<\/td><td>Refreshing the version of static content only can be used to refresh static content in browser cache and CDN cache.<\/td><\/tr><tr><td>&#8211;no-javascript<\/td><td>Do not deploy JavaScript files.<\/td><\/tr><tr><td>&#8211;no-css<\/td><td>Do not deploy CSS files.<\/td><\/tr><tr><td>&#8211;no-less<\/td><td>Do not deploy LESS files.<\/td><\/tr><tr><td>&#8211;no-images<\/td><td>Do not deploy images.<\/td><\/tr><tr><td>&#8211;no-fonts<\/td><td>Do not deploy font files.<\/td><\/tr><tr><td>&#8211;no-html<\/td><td>Do not deploy HTML files.<\/td><\/tr><tr><td>&#8211;no-misc<\/td><td>Do not deploy files of other types (.md, .jbf, .csv, etc.).<\/td><\/tr><tr><td>&#8211;no-html-minify<\/td><td>Do not minify HTML files.<\/td><\/tr><tr><td>-h<\/td><td>&#8211;help<\/td><td>Display this help message<\/td><\/tr><tr><td>-q<\/td><td>&#8211;quiet<\/td><td>Do not output any messages<\/td><\/tr><tr><td rowspan=\"3\">-V<\/td><td>&#8211;version<\/td><td>Display this application version<\/td><\/tr><tr><td>&#8211;ansi<\/td><td>Force ANSI output<\/td><\/tr><tr><td>&#8211;no-ansi<\/td><td>Disable ANSI output<\/td><\/tr><tr><td>-n<\/td><td>&#8211;no-interaction<\/td><td>Do not ask any interactive question<\/td><\/tr><tr><td>-v|vv|vvv<\/td><td>&#8211;verbose<\/td><td>Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Simply run the below command to deploy static content in your store when you install an extension<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>php bin\/magento setup:static-content:deploy -f<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">That was all about the <em><strong>Magento 2 Static Content Deploy<\/strong><\/em>!<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Follow the guide that&#8217;ll help to boost the speed of your Magento 2 store!<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Thank you<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The tutorial includes the stepwise method to deploy static content in Magento 2. Trace the static view files in the static directory of your Magento&#8230;<\/p>\n","protected":false},"author":5,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[34],"tags":[],"class_list":["post-385","post","type-post","status-publish","format-standard","hentry","category-magento"],"acf":[],"_links":{"self":[{"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts\/385","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/comments?post=385"}],"version-history":[{"count":3,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts\/385\/revisions"}],"predecessor-version":[{"id":19118,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts\/385\/revisions\/19118"}],"wp:attachment":[{"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/media?parent=385"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/categories?post=385"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/tags?post=385"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}