Html Helper link for css file does not locate webroot

Beginner here…
Currently the home page loads without the CSS files.
The code is in home.php and it uses
<?= $this->Html->css(['normalize.min', 'milligram.min', 'cake', 'home']) ?>
to access its css files.

My browser shows that, CakePHP is trying to find the file in “/pkm/css/normalize.min.css” (Project name is pkm).
Whereas, it should be trying to access “/pkm/webroot/css/normalize.min.css”.

I tried to retrace but that has been quite difficult,
Please be in mind that I’d like to keep the file in the webroot file if possible.

Thank you!


Additional:
From var_dump(debug_backtrace())
[“base”:protected]=> string(4) “/pkm” [“webroot”:protected]=> string(5) “/pkm/”
Directory:

The webroot folder is actually the top level folder on the web-page. So say you put that folder itself hello.html with the text Hello, then going to your website www.blah.com/hello.html will show that “Hello”. Also your .htaccess for the top-level of your webpage goes into webroot.

The root folder of the app is one level above the public www folder. Therefore your css, js & font etc folders go within the webroot one.

Thanks, I’m not sure if I understood you correctly but the CSS files were always in the webroot folder

I hope what I’m saying is correct, but your browser should be completely unaware of the name of your project - in that its a level above what the browser can see. So if its saying its trying to load the css from a folder that includes the path which has the name of your app then maybe the webroot folder isn’t configured correctly. In which case check your /config/paths.php has define('WWW_ROOT', ROOT . DS . 'webroot' . DS); .

Otherwise bake a brand new test app and see if its pulling in milligram.min.css etc; and if so run WinMerge (or equivalent) to spot the differences in configurations.

1 Like

I’ll try, thank you!