The frontend is not loading perfectly in Magento 2.4.3. I tried refreshing the cache in admin but that didn't fix the issue. I assume that the theme files are not loading but we are unable to find a correct solution for this. What steps should we take to resolve this issue?
3 Answers
Remove the generated folder and run the below command
php bin/magento set:up
php bin/magento s:s:d -f
Also, Check If you're facing any errors while running this command.
check .htaccess file in pub/static folder if not there place it from git and run deployment
Try below command first if not fix your issues then follow other step as below.
find . -type f -exec chmod 644 {} \;
find . -type d -exec chmod 755 {} \;
sudo rm -rf pub/static/frontend rm -rf pub/static/adminhtml rm -rf pub/static/_cache rm -rf var/cache rm -rf var/composer_home rm -rf var/generation rm -rf var/generated rm -rf var/page_cache rm -rf var/view_preprocessed rm -rf var/log rm -rf var/report rm -rf generated/code/ rm -rf generated/metadata/
php bin/magento maintenance:enable
php bin/magento setup:upgrade
php bin/magento setup:static-content:deploy -f
php bin/magento setup:static-content:deploy --theme Magento/backend -f
php bin/magento setup:di:compile
php bin/magento maintenance:disable
php bin/magento cache:flush
php bin/magento indexer:reindex
sudo chmod -R 777 var/ generated/ pub/media/ pub/static/
Here is the simplest solution if showing version name in CSS path
like : pub/static/version323334/
then run this query in my SQL
INSERT INTO core_config_data (path, value)
VALUES ('dev/static/sign', 0)
ON DUPLICATE KEY UPDATE value = 0;
after that clear the config cache
bin/magento cache:clean config
IF the Above simple does not work then please try the below::
SOLUTION # 1 (IF YOU WANT TO EDIT XML FILE)
Now we are going to clear / delete caches and sessions of Magento 2. Go to following paths and delete everything:
ROOT > var > cache > *DELETE ALL*
ROOT > var > page_cache > *DELETE ALL*
ROOT > var > session > *DELETE ALL*
When Magento 2 is not in production mode, it will try to create symlinks
for some static resources on local server. We have to change that behavior of Magento 2 by going to edit ROOT > app > etc > di.xml
file. Open up di.xml
in your favorite code editor, find the virtualType name="developerMaterialization"
section. In that section below, you will find an item <item name="view_preprocessed" xsi:type="object">
which needs to be modified. You can modify it by changing the following content:
Magento\Framework\App\View\Asset\MaterializationStrategy\Symlink
To:
Magento\Framework\App\View\Asset\MaterializationStrategy\Copy
Now last step, also delete old files generated in ROOT > pub > static > DELETE ALL EXCEPT .HTACCESS
In this step, we are setting up static content to deploy on our Magento store. To perform this below step again.
php bin/magento maintenance:enable
php bin/magento setup:upgrade
php bin/magento setup:static-content:deploy -f
php bin/magento setup:static-content:deploy --theme Magento/backend -f
php bin/magento setup:di:compile
php bin/magento maintenance:disable
php bin/magento cache:flush
php bin/magento indexer:reindex
sudo chmod -R 777 var/ generated/ pub/media/ pub/static/
You are done with successful configure of Magento 2.