GAURANG VYAS GAURANG VYAS - 2 months ago 22
CSS Question

External CSS in Laravel 5.2 project

I am currently using Laravel 5.2 framework for my web dev project and stuck on problem. In my dashboard.blade.php i want specify the link to an external css file which is in public/src/css/main.css.
I used URL::to() and URL::asset() methods to get the absolute path to the CSS file but still it is not working.
When i placed my CSS file just inside the public directory everything worked fine but when i place it inside any subdirectory in the public directory it doesnot work.
I am homestead along with the laravel as development environment.

dashboard.blade.php file

dashboard.blade.php file

directory structure of the project

directory structure of the project

Answer

No matter where you place your css file inside public folder you can get it using the code :

<link rel=stylesheet" href="{{asset('src/css/main.css')}}">

For this code place your css file inside public/src/css
In your image of directory there is no folder as css inside src