Laravel 5 Not Finding CSS Files

Laravel 5 not finding css files

Use this to add assets like css, javascript, images.. into blade file.

FOR CSS,

<link href="{{ asset('css/app.css') }}" rel="stylesheet" type="text/css" >

OR

<link href="{{ URL::asset('css/app.css') }}" rel="stylesheet" type="text/css" >

FOR JS,

<script type="text/javascript" src="{{ asset('js/custom.js') }}"></script>

OR

 <script type="text/javascript" src="{{ URL::asset('js/custom.js') }}"></script>

FOR IMAGES,

{{ asset('img/photo.jpg'); }}

Here is the DOC

Alternatively, if you pulled the composer package illuminate/html which was come as default in laravel 4.2 then you can use like below, In laravel 5. you have to manually pull the package.

{{ HTML::style('css/style.css') }}

Here is an Example.

Why my css file is not loading in laravel?

You're trying to access the resources folder, which is not exposed to the public, you'll have to compile your css so it lives in the public folder, which is the folder that anyone(including your frontend) can access using https://your-url.tld/{public file path}. There are 2 ways in which you can have your user.css file available for to your frontend:

One:

You can import your user.css file to the existing resources/css/app.css file:

/* app.css file */
@import "../path/to/user.css";

Two:

You can compile user.css to a separate file, in case you want to use that file specifically on another layout or blade file instead of mixing it globally with the app.css file:

// webpack.mix.js file
mix.js('...')
.css('resources/css/user.css', 'public/css');

Then in your layout file:

// app.blade.php file
<link rel="stylesheet" href="{{ asset('css/user.css') }}">

Hope it helps.

CSS files are not loading in Laravel view

The CSS files not loading is related to an error in the file path. You forgot the css folder inside the bootstrap-* folder

{{ asset('assets/bootstrap-4.1.3/css/bootstrap.min.css') }}

The error shown in the screenshot is more related to a view not being found or an url/ route not defined.

auth pages not getting css in laravel

Step 1:

  • Download nodejs
  • Install nodejs in your pc

Step 2:

  • then open your project root and command
  • composer require laravel/ui
  • php artisan ui vue --auth
  • npm install
  • npm run dev

After npm command it will generate node_module folder inside your project remove that folder.

npm command only for .css and .js file.

for help see this video: https://www.youtube.com/watch?v=hOYW3jqh19I&t=9s

Laravel App Not Loading CSS From Public Installation Not In public_html

You can try to put public directory path in below given conflagration file.

Config File Path : config/app.php (asset_url)

 'asset_url' => env('ASSET_URL', 'https://test.mydomain.com/public/')

Laravel 5.7 cannot read css file

First, check whether it is loaded or not by opening the developer tools.
Second, while developer tools is open, right-click the refresh icon and click on the "Empty cache and hard reload" option.
Third, restart laravel server.

Why laravel can't find the css file?

You don't need to reference the public folder explicitely, because this is already the web root (at least it is when the web server is configured correctly, also for security reasons). In other words, the browser only sees the content of the public directory - everything else is pulled in by the framework.

This means <link href="css/blog.css" rel="stylesheet"> should be enough. Alternatively, you can also go for <link href="{{ asset('css/blog.css') }}" rel="stylesheet">.



Related Topics



Leave a reply



Submit