Magento Path to CSS and JS incorrect

Magento Path to CSS and JS incorrect

September 11, 2026 · Illustrated author avatarBy Stefan Bogdanescu
Magento Path to CSS and JS incorrect

Solving Magento CSS & JS Path Issues: A Comprehensive Guide

Dear Developer,

If you’re reading this, chances are your Magento store is experiencing critical issues with CSS and JavaScript files that are breaking the site’s appearance after cache clearing. Don’t worry; we’ve all been there, and I’m here to help you troubleshoot this problem step by step.

The Common Culprits

Before diving into solutions, let’s understand why this happens:

  1. Incorrect Base URLs: If your base URLs (web and secure) are not properly configured in the System > Configuration > General > Web section, Magento won’t be able to locate your CSS and JS files correctly after cache clearing.

  2. Permission Issues: Inadequate permissions on folders like pub/static, var/cache, or media can prevent Magento from serving static resources.

  3. Merge CSS/JS Settings: The “Merge JavaScript Files” and “Merge CSS Files” settings in the Developer > Frontend section might be enabled, leading to broken files after cache flushing.

  4. Development Mode: If your store is in development mode (enabled by the developer cookie), it may serve uncompiled assets that break in production environments.

Step-by-Step Solutions

1. Check Base URLs and Media Folder Permissions

First, ensure your base URLs are correct. They should point to the root directory of your Magento installation:

Web: http://isaacgrainger.co.uk/
Secure: https://secure.isaacgrainger.co.uk/

Next, check folder permissions:

  • pub/static should have 644 permissions for files and 755 for directories.
  • var/cache, var/tmp, and media folders should also be 755.

You can use the following commands to adjust permissions:

chmod -R 755 pub/
chmod -R 755 var/
chown -R apache:apache .

2. Disable CSS/JS Merge and Minify

Navigate to System > Configuration > Advanced > Developer > Frontend.

Set “Merge JavaScript Files” and “Merge CSS Files” to “No.”

Do the same for “Minify HTML,” “CSS,” and “JavaScript” options if they are enabled.

3. Verify the Presence of Compiled Assets

After clearing cache (System > Cache Management > Flush Magento Cache), check the following paths for compiled assets:

pub/static/frontend/<theme_name>/<locale_code>/registration.json

If these files exist, then your CSS and JS are being successfully recompiled.

Ensure you’re not in development mode by checking your cookies for a developer key-value pair. If present, clear the cookie to ensure production-level resources are served.

When All Else Fails: Recompile Assets Manually

If nothing works, you can manually recompile your assets using the following command:

php bin/magento setup:static-content:deploy -f

The -f flag forces a deployment even if there are no changes detected. This ensures all CSS and JS files are regenerated.

Conclusion

Recovering from broken Magento stores due to CSS/JS path issues requires patience, attention to detail, and systematic troubleshooting. By following the steps outlined above—checking base URLs, permissions, settings, and manually recompiling assets if necessary—you should be able to resolve most cases of this common problem.

Remember, maintaining proper folder permissions, keeping your Magento version up-to-date, and using a reliable hosting provider can help prevent these issues from occurring in the first place.

For more advanced troubleshooting techniques and best practices for Magento development, feel free to explore our comprehensive resources at Laravel Company.

Don’t hesitate to reach out if you need further assistance or have any questions. Happy coding!

Catalog Cache Security Themes

Our network