Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange
53

As of 2.1.1 you can now deploy specific themes or exclude themes: Deploy specific themes: php bin/magento setup:static-content:deploy --theme Magento/backend --theme Vendor/mytheme Exclude themes: php bin/magento setup:static-content:deploy --exclude-theme Magento/luma Update these options are now in the documentation.


44

SOLUTION # 1 (IF YOU WANT TO EDIT XML FILE) I would like you to download Magento 2 zip from magentocommerce.com/download with sample data, create new db in phpmyadmin, extract zip in htdocs folder. Install Magento 2 but do not use localhost use 127.0.0.1 in store URL and admin URL. After successful installation DO NOT run magento. Now we are going to clear ...


30

TL;DR truncate pub/static folder. For me, I had an older installation, which probably had some symlinks and old files which no longer exist. The issue checkInstallationFilePermissions is that it checks the permissions recursively. Files and folders. I had a missing symlink, and that returned false on the check if it's writable. How to debug: setup/src/...


27

pay attention: I've experienced that in developer mode deleting the pub/static will break the mechanism because you get rid of the .htaccess file that makes the magic in that folder. If you keep the pub/static/.htaccess file in developer mode you don't need to run any compilation command: Magento will create symlinks to files as soon as they are requested. ...


25

The main issue was caused by the incorrect rewrites work ( as @Marius told ). There was no RewriteBase in my directory pub/static/ and Apache could not find the files because searched for them from the root folder. After we’ve added: RewriteBase /pub/static everything start working. How it worked: by this address: http://m2.uchuhlebov.web.ra/pub/...


24

I'm afraid that you just can't deploy only one theme by magento console setup:static-content:deploy command. I've been dealing with M2 frontend development for the last 2 weeks and I can affirm that the dev process it's a real PAIN! You'll lost a lot of time deploying changes due to complexity of less files hierarchy and themes fallbacks. Anyway I'm ...


19

Need to update in Database core_config_data table, If record (path field value = 'dev/static/sign') exist in core_config_data table UPDATE core_config_data SET value = 0 WHERE path = 'dev/static/sign' If record not exist then run below query to Insert record, INSERT INTO core_config_data VALUES (null, 'default' , 0, 'dev/static/sign', 0); After that run ...


15

In Magento 2 you are able to content deploy specific themes and also exclude themes by this commands: Content Deploy specific themes By this command: php bin/magento setup:static-content:deploy --theme Vendor/firsttheme --theme Vendor/secondtheme Exclude themes By this command: php bin/magento setup:static-content:deploy --exclude-theme Vendor/yourtheme ...


12

Magento allows to provide static asset files per locale in the module or theme. To provide such localized files, put them under web/i18n/<locale> folder inside the module or a theme. These files have priority above non-localized files.


12

Magento 2 follows Mobile First approach and @media-common = true was designed to define styles that are base (mobile) and must be present in styles-m.css. If you drop this declaration styles will be outputted both to styles-m.css and styles-l.css files.


11

I ran into this error in development because of a broken symbolic link. I had created a file in a module's view/frontend/web directory that in developer mode was deployed to the pub/static directory using a symbolic link that pointed to the module's directory where the original file is stored. At some point in development I removed the file from my module,...


10

If you are facing problem of css and js page load design after installation in magento2 please follow the following step-: open the terminal and navigate to magento web root $ cd /var/www/html/magento2 Step 1. $ php bin/magento setup:static-content:deploy Step 2. $ php bin/magento indexer:reindex Step 3. make sure apache “rewrite_module” is ...


8

you just need to update the apache2.conf file. On Ubuntu 16.04 Open and edit the file /etc/apache2/apache2.conf Navigate to the place in the apache2.conf file <Directory /var/www/> Change "AllowOverride None" to "AllowOverride All" Save the file Restart apache2 -> sudo service apache2 restart


8

Try to use: echo $block->getViewFileUrl('Company_Helloworld::yourImage.png'); As a second argument of \Magento\Framework\View\Element\AbstractBlock::getViewFileUrl($fileId, array $params = []) you can set an array of next parameters: "module", "_secure", "theme", "area" and "locale"


8

I reckon there's several types of errors that can be triggered by the deployment. First you can see that Exception are handled directly in the execution in Magento/Deploy/Console/Command/DeployStaticContentCommand.php: catch (\Exception $e) { $output->writeln('<error>' . $e->getMessage() . '</error>>'); if ($output-&...


8

By Default magento 2 with sample data with luma themes used Widget to display static content in homepage and all parent category(What's New, Women, men, gear etc..) in luma theme. In Luma Themes all static block and Top category page called from Widget. You can check widget from Content -> Elements -> Widget There are list of widget are available ...


8

If you are running Nginx, here is the fix. You probably have your own conf file, you need to update the /static/ part with this, they have updated part of it specifically: # Remove signature of the static files that is used to overcome the browser cache section: location /static/ { # Uncomment the following line in production mode # expires max; ...


7

I was able to resolve this by adding this node in app/etc/di.xml <type name="Magento\Deploy\Model\Deploy\LocaleDeploy"> <arguments> <argument name="assetPublisher" xsi:type="object">developerPublisher</argument> </arguments> </type> For magento 2.2 code will be <type name="Magento\...


7

first run the cmd composer install in you folder then run this cmd php bin/magento setup:upgrade php bin/magento setup:di:compile php bin/magento setup:static-content:deploy php bin/magento indexer:reindex php bin/magento cache:flush after setup:upgrade you remove the generation, page_cache, cache, view_preprocessed, static rm -rf var/generation/*


7

First, make sure apache “rewrite_module” is enable and then restart the server. If this hasn't worked. Then do following steps: Edit the file /etc/apache2/apache2.conf. Find this code: <Directory /var/www/> Options Indexes FollowSymLinks AllowOverride None Require all granted </Directory> Change "AllowOverride None" to ...


6

In my own case, I ran php bin/magento setup:static-content:deploy and the error disappeared.


5

Try to disable cache if you do not disable it before Make sure you have the latest version of Magento with clean code. If you modify or customize something make sure fix all errors. Run several commands below may help you. php bin/magento indexer:reindex php bin/magento cache:flush Remove folders in pub/static/frontend/* var/cache var/view_preprocessed/* ...


5

I had the same issue resolved by adding sudo nano /etc/apache2/apache2.conf Modify this <Directory /var/www/> Options Indexes FollowSymLinks AllowOverride None Require all granted </Directory> to this <Directory /var/www/html> Options Indexes FollowSymLinks AllowOverride All Require all ...


5

if you create your theme inside app/design/yourVendor/Youtheme and activated your theme the assets url will be change to : http://example.magento.com/static/frontend/yourVendor/Youtheme/en_US/Pulsestorm_FrontendTutorial1/hello.js Magento create hello.js for every theme already declared inside registration.php , Magento equal yourVendor (almost interface for ...


5

you can make your function as a jQuery UI widget and then call it from the template and sending the image url as a parameter. For an idea on how to create a UI widget you can check how the configurable products widget is built and how it is called in the frontend with parameters I know there are better examples but this is the first one I found that has ...


5

The "Magento 2" way to do this would be Initialize your script as a RequireJS module using the x-magento-init <script/> tag, using the * feature so its not bound to a DOM element as a Magento jQueryUI style widget Use PHP to dynamically generate the JSON object you'll pass into your script


5

This error occurs when you do not have php's intl extension. For futher info. you can chk https://github.com/magento/magento2/issues/2316 Run Grunt deploy task -> Fatal error: Class 'Locale' not found Error in Magento 2 when trying to deploy


5

This is due to Magento "Signing" the files. Essentially it forces Magento to regenerate the public static files on page reload by adding the current timestamp to the files. This may have changed due to an upgrade of version so check the following configuration is set to no: Store -> Configuration -> Developer -> Static Files Settings -> Sign ...


5

you can tell Magento not to get rid of generated code and static files: magento setup:upgrade --keep-generated From docs: where --keep-generated is an optional argument that does not update static view files. This optional argument is for use only in limited circumstances by experienced system integrators. It should be used only in production ...


5

EDIT: This describes why it was failing and a way to work around it, but JNDPNT/Altravista has the right answer so I updated. Trouble is, we want to run setup:upgrade as late in the deploy process as possible - in the chance something happens to bail the deploy, allows easier rollback than after setup:upgrade has run. It's unfortunate to have to change this ...


Only top voted, non community-wiki answers of a minimum length are eligible