Hot answers tagged

79 votes
Accepted

Magento2: Re generate css file in pub/static folder

Before deleting pub/static make a backup of pub/static/.htaccess and restore it again. otherwise your all css and js will show 404 error! Remove pub/static (keep the .htaccess backed up and copy it ...
user avatar
74 votes

magento 2 admin url not working and loaded frontend is all messy

First of all, apply proper permissions, enable apache rewrite_module and refresh apache server. chmod -R 777 /var/www/html/MAGENTO_2_ROOT_DIRECTORY/ sudo a2enmod rewrite sudo service apache2 ...
user avatar
  • 4,636
64 votes

Magento 2 custom theme layout xml and css not working

Check your DB. There is a table called theme that stores a reference to all the themes that have ever been installed in your store. If the type of the theme is set to 1, that means Magento sees the ...
user avatar
  • 4,173
59 votes
Accepted

How to add a custom CSS file in Magento 2

In order to do add custom css and load last, you must set up a custom theme. Create theme: http://devdocs.magento.com/guides/v2.0/frontend-dev-guide/themes/theme-create.html Make sure that you set ...
user avatar
  • 2,129
50 votes

Less files in custom modules

You need to upgrade the source to include the @import command in the style-l.less file with:- php bin/magento setup:upgrade Then you need to deploy static content to compile your less files with:- ...
user avatar
44 votes
Accepted

Magento CSS and JavaScript not loading due to using file system path

Magento using full path urls to access CSS files is a common error that results from two things happening: Having Merge CSS Files Enabled Magento being unable to read/write to the media/ folder. To ...
user avatar
  • 1,662
40 votes
Accepted

Magento 2 : How to add custom css for adminhtml?

1 Create a module for example Vendor/Module, this _means a fully working module, including registration.php file etc. 2 Create a new file view/adminhtml/layout/default.xml in the module: <?xml ...
user avatar
30 votes

How to add Bootstrap 4 in a Magento 2 theme?

For adding Bootstrap 4 In Magento 2.2.3 (tested) & above in your custom theme follow below steps 1) Bootstrap css files inside web folder Note: THEME_LOCATION => app\design\frontend\vendor-...
user avatar
  • 5,719
25 votes

Magento2: Re generate css file in pub/static folder

answers here don't mention that you shouldn't delete the .htaccess in the pub/static folder. to delete all files except the .htacces enter the pub/static directory and run cd /pub/static/ find . -...
user avatar
25 votes
Accepted

Running php bin/magento setup:static-content:deploy for different languages

bin/magento setup:static-content:deploy en_GB or if you want for multiple languages: bin/magento setup:static-content:deploy en_GB en_US ro_RO
user avatar
  • 196k
24 votes
Accepted

Magento 1.9 : Add custom css file to head

There are two way to add css to head one is using function addCss and another is addItem. You have mix-up two format. Your format is wrong. try this <action method="addCss"> <...
user avatar
  • 75.8k
23 votes
Accepted

Magento 2: Override/extend the email.css that is being used in the transactional email header

You can check the official documentation here : http://devdocs.magento.com/guides/v2.1/frontend-dev-guide/templates/template-email.html The general steps : Create a Magento 2 frontend theme Upload ...
user avatar
22 votes

Merged JS and CSS do not work when Production mode

I just did the following and the problem was solved: bin/magento setup:upgrade bin/magento indexer:reindex bin/magento deploy:mode:set production -s # Here was the secret: run the di:compile after ...
user avatar
  • 1,323
22 votes

Refused to apply style "because its MIME type ('text/html') is not a supported stylesheet MIME type"

Recently had a very similar issue with a Magento 2 site. Managed to track down the issue to a very important .htaccess file missing in the pub/static folder on the server. It's unclear how this file ...
user avatar
20 votes
Accepted

Magento2: Best practice to modify css files

You should not edit/modify files within pub/* or vendor/* directory. Pub is for deployment and vendor is for default structure, which you override via your template or custom modules. Instead: create ...
user avatar
  • 701
20 votes

Magento 2 : How to add custom css for adminhtml?

Magento 2 uses less file so you can also use less type as follows below step. Create new file at Vendor/Module/view/adminhtml/web/css/source/_module.less after that run below command from root ...
user avatar
19 votes
Accepted

Static content deploy issue

Solution is deprecated: Do not Not used it. Bad idea to switch to default It got a solution, which may not be 100% right. First I change change current application mode to default from developer at ...
user avatar
  • 75.8k
19 votes
Accepted

Magento 2 - How can I add custom template file into <head>?

If you want add css file into head you can use this code: <head> <css src="path_to/file.css" /> </head> But if you need to add custom block into head, you can use this code: &...
user avatar
18 votes

Clear Theme/CSS Cache in Magento 2

I think right way to refresh .less files now it's php bin/magento setup:static-content:deploy Because it "Collects, processes and publishes source LESS files" Another point it's use dev mode ...
user avatar
  • 2,100
18 votes

How to add a custom CSS file in Magento 2

In order to add custom css and load last Follow the directory structure app / code / vendor / modulename / view / frontend(for admin adminhtml) / web /css / filename.css Add the css file path to ...
user avatar
  • 3,028
17 votes

Overriding Blank Theme Styles in Magento 2

The 2 ways recommended by Magento to override or extend the styles from a parent theme: 1. Simple way Extend: In your theme directory, create a web/css/source sub-directory. (You've already done ...
user avatar
  • 1,579
16 votes

How do I disable merged CSS and JS

go to database and execute this query SELECT * FROM core_config_data WHERE path LIKE 'dev%' change these value from 1 to 0 dev/js/merge_files dev/css/merge_css_files
user avatar
  • 32.1k
16 votes

What is the proper way of positioning/ordering CSS files in Magento 2?

Magento2 has no built-in mechanism for this so I decided to treat it as an opportunity to write my first Magento2 extension. The Quickshiftin\Assetorderer extension is now available on GitHub! Once ...
user avatar
  • 1,366
16 votes
Accepted

Magento 2: style-m.css vs style-l.css

These files are generated through LESS. In theory style-m.css should have less code and to have styles only for mobile devices than style-l.css in order to load on mobile devices faster. This is ...
user avatar
  • 1,287
15 votes

Magento 2: Not loading CSS and JS after successful installation in windows

Its working when i did the following changes: Remove all files from pub/static folder but not .htaccess Go to app/etc/di.xml Replace ('Symlink' --> 'Copy') Magento\Framework\App\View\Asset\...
user avatar
15 votes

Refused to apply style "because its MIME type ('text/html') is not a supported stylesheet MIME type"

The problem is caused due to the permission issue on the static files. To fix this issue, 1) Go to file path pub/static/ 2) Check whether .htaccess file is available (hidden file - Press cntrl+H ...
user avatar
13 votes

how to add expires headers in magento

Try to put this in .htaccess <ifModule mod_expires.c> ExpiresActive On ExpiresDefault "access plus 2 days" ExpiresByType image/x-icon "access plus 2592000 seconds" ExpiresByType ...
user avatar
  • 389
13 votes

magento 2 admin url not working and loaded frontend is all messy

For those who are using wamp server on windows localhost then, you can try this: C:\wamp\bin\php\php5.5.12>php.exe C:\wamp\www\<Magento root directory>\bin\magento setup:static-content:...
user avatar
  • 1,730
13 votes
Accepted

Load Custom CSS After style-l.css For Home Page

Here is the short answer: Magento load all css assets into asset groups. Asset groups are created based on the css properties and which is what stands crucial for the rendering order of css assets. ...
user avatar
12 votes

Magento2: After delete pub/static folder and making deploy, no css files found

You need to run grunt exec and then grunt less.
user avatar
  • 159

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