Skip to main content
Share Your Experience: Take the 2024 Developer Survey
73 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 ...
Anil Suthar's user avatar
  • 4,731
68 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 ...
circlesix's user avatar
  • 4,293
61 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 ...
Joshua34's user avatar
  • 2,317
54 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:- ...
Dallas Clarke's user avatar
45 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 ...
Krishna ijjada's user avatar
33 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-...
Manoj Deswal's user avatar
  • 5,805
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 . -...
Claudiu Creanga's 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
Marius's user avatar
  • 198k
23 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 ...
Technocracker's user avatar
23 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 ...
Aaron's user avatar
  • 330
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 ...
user37025's user avatar
  • 1,383
22 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 ...
Franck Garnier's user avatar
19 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 ...
Manish's user avatar
  • 3,116
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 ...
Amit Bera's user avatar
  • 77.5k
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: &...
Ihor Klymchuk's user avatar
18 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 ...
Luis Garcia's user avatar
  • 1,639
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 ...
quickshiftin's user avatar
  • 1,426
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 ...
TiEul's user avatar
  • 1,297
16 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 ...
Sathishkumar's user avatar
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\...
Amrith Prakash's user avatar
15 votes

Magento 2 - css source maps not working

In magento 2.4.4 I had same problem. I fixed it by downgrading to "grunt-contrib-less": "1.4.1" in package.json and running npm install again.
Vince Verhoeven's user avatar
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:...
MaYaNk's 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. ...
Rajeev K Tomy's 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.
Aaron's user avatar
  • 259
12 votes
Accepted

Magento 2: Email Templates Template Style is not Working

First of all, we need to read here: http://devdocs.magento.com/guides/v2.1/frontend-dev-guide/templates/template-email.html#non-inline-styles. For the Non Inline Styles, they must be in a <style ...
Khoa TruongDinh's user avatar
12 votes
Accepted

Magento 2 - overwrite module Less / css with theme

Put an empty file in here {theme}/Vendor_Module/web/css/source/_module.less. The blank file will override the module's _module.less file. You shouldn't need to bother with the other .less files. ...
Aaron Allen's user avatar
  • 9,009
12 votes

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

I had the same issue this morning. I updated Sales email templates, then suddenly admin pages stopped working. The problem was solved when I re-deployed the assets for admin pages. I run these ...
Yas Nakano's user avatar
11 votes
Accepted

Magento2 CSS IE hacks

Then you can use following code: <head> <css src="css/ie-8.css" ie_condition="IE 8" /> </head> Good luck! :)
Bartłomiej Szubert's user avatar
11 votes
Accepted

Accidentally deleted .htaccess file inside pub/static folder

You can download corresponding file from the official Magento 2 repository. That will solve your problem.
Siarhey Uchukhlebau's user avatar
11 votes

How to add Bootstrap 4 in a Magento 2 theme?

You can add Bootstrap this way, follow below steps: Note: This solution doesn't work with Magento 2.2.3 and above 1) Place your JS and CSS at below location /app/design/frontend/vendor-name/...
Mayur Rathod's user avatar

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