LaurenFrida
LaurenFrida

Reputation: 329

Magento2 doesn't load images and css

I have downloaded and installed Magento 2 but I'm getting 404 error for scripts and css. An example of my image path is: http://www.arredomobilionline.com/pub/static/frontend/Magento/luma/it_IT/images/logo.svg

I've already tried this solution:

Open up app/etc/di.xml and find the virtualType name="developerMaterialization" section. In that section you'll find an item name="view_preprocessed" that needs to be modified or deleted. You can modify it by changing the contents from Magento\Framework\App\View\Asset\MaterializationStrategy\Symlink to Magento\Framework\App\View\Asset\MaterializationStrategy\Copy

inside my deafult di.xml file as default there's:

    <virtualType name="developerMaterialization" type="Magento\Framework\App\View\Asset\MaterializationStrategy\Factory">
    <arguments>
        <argument name="strategiesList" xsi:type="array">
            <item name="view_preprocessed" xsi:type="object">Magento\Framework\App\View\Asset\MaterializationStrategy\Symlink</item>
            <item name="default" xsi:type="object">Magento\Framework\App\View\Asset\MaterializationStrategy\Copy</item>
        </argument>
    </arguments>
</virtualType>

I tried to delete the first symlink part or change it into "copy" but it's not working. I've also set 777 permission to every file.

Upvotes: 1

Views: 2945

Answers (5)

Abhinav Kumar Singh
Abhinav Kumar Singh

Reputation: 2325

Execute the following commands to eliminate 404 error for scripts and css:

php bin/magento setup:static-content:deploy
php bin/magento indexer:reindex
php bin/magento cache:flush

Upvotes: 0

Ketan Borada
Ketan Borada

Reputation: 864

Use below command for import sample data and load css/js

php bin/magento setup:static-content:deploy
php bin/magento indexer:reindex
php bin/magento cache:flush

and check affected folder pub\static\

Upvotes: 4

GunJan Mehta
GunJan Mehta

Reputation: 312

I think after installing composer, you should try

php bin/magento setup:static-content:deploy

If you are going to develop a theme this will be needed to run on every change or you need to find some other solution

Upvotes: 1

samumaretiya
samumaretiya

Reputation: 1175

The following steps are worked for me

You need delete files from public/static/frontend and also var/cache

step 1. php bin/magento setup:static-content:deploy

For more information visit this blog

https://samumaretiya.wordpress.com/2016/01/09/javascript-magento-2-not-loading-css-and-js/

Upvotes: 0

Rahul Singh
Rahul Singh

Reputation: 199

This One Worked for Me. use this in Terminal "php bin/magento setup:static-content:deploy"

Step 1 : In CMD Open your root directory using cd command

Step 2 : "php bin/magento setup:static-content:deploy" - run this Command

then,Check Your pub/static folder, CSS and Js files will be available there

Upvotes: 0

Related Questions