Why laravel can't find the css file? - laravel

I am using the following line to add the CSS file:
<link href="public/css/blog.css" rel="stylesheet">
And in source file I see it's showing:
<link href="public/css/blog.css" rel="stylesheet">
but somehow laravel can't find this CSS file!
Even I have used following line:
<link href="{{ URL::asset('public/css/blog.css') }}" rel="stylesheet" type="text/css" >
and in source file it's showing:
<link href="http://localhost:8000/public/css/blog.css" rel="stylesheet" type="text/css" >
But no luck!. it's saying:
Sorry, the page you are looking for could not be found.

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">.

Try without public in your link:
<link href="/css/blog.css" rel="stylesheet">
and also check that blog.css exists in the folder: public/css
Your webserver should use Laravel's public folder as root folder.

Related

Laravel. Where Should I put CSS files?

I put file name style.css in {Laravel_project}/public/css/
I included in blade file like this.
<link rel="stylesheet" type="text/css" href="{{ asset('css/style.css') }}" >
and then checked its source on browser.
<link rel="stylesheet" type="text/css" href="http://localhost:8000/css/style.css" >
the file doesn't exist.
404
Not Found
Laravel version
$ php artisan --version
Laravel Framework 7.11.0

laravel - adding custom files in the public folder

I am trying to add custom css and js files to the laravel public folder and I dont want to use the the default css and js folders. I created a folder and tried linking to it with my blade and its returning a 404
<!-- Styles -->
<link href="{{ asset('css/app.css') }}" rel="stylesheet">
<link href="{{ asset('open-iconic/font/css/open-iconic-bootstrap.css') }}" rel="stylesheet">
adding open-iconic-bootstrap.css to the css folder works but I am trying to use a customer folder. Am I missing a step on getting this to work?
404 is app.css or open-iconic-bootstrap.css ?
you don't need link the css\app.css and js\app.js
and delete the line <link href="{{ asset('css/app.css') }}" rel="stylesheet">
check the correct path open-iconic/font/css/open-iconic-bootstrap.css

Laravel 5.5 css path is not working under public directory

I have used the following to generate the CSS file:
<link rel="stylesheet" href="{{ asset('public/global/bower_components/bootstrap/dist/css/bootstrap.min.css') }}">
However, I see the css is not loading. From the view source, I see the below code which is not opening (404).
<link rel="stylesheet" href="http://127.0.0.1:8000/public/global/bower_components/bootstrap/dist/css/bootstrap.min.css">
But, if I remove the "public keyword" from the above path, its working.
I'm using php artisan serve in Ubuntu 16.04
<link rel="stylesheet" href="{{ public_path('global/bower_components/bootstrap/dist/css/bootstrap.min.css') }}">
<link rel="stylesheet" href="http://127.0.0.1:8000/global/bower_components/bootstrap/dist/css/bootstrap.min.css">
these two works. Because when 127.0.0.1:8000 load, it starts making the project from public path.
and asset(/path) is represent asset folder. You must change this with public_path
You can use asset() helper,
<link href="{{ asset('public/global/bower_components/bootstrap/dist/css/bootstrap.min.css') }}" type="text/css" rel="stylesheet">

Laravel structure broken after deploying in shared host

i am deploying my project to shared hosting now. But i found that all the css file seem like not in correct directory. For example my original code is <link href="{{ asset('intro/css/style.css') }}" rel="stylesheet" type="text/css">
In server i need to change it to
<link href="public/intro/css/style.css" rel="stylesheet" type="text/css"> in order to make it work.
But i having thousand of line need to change if i had to update all.
Is there others way to do it?
I am using Cpanel and my file is located in public_html.
Try this
<link href="{{URL:: asset('intro/css/style.css') }}" rel="stylesheet" type="text/css">

How do i call css file in laravel?

Good day. I'm trying to call css in laravel. Here is the css url
<link rel="stylesheet" href="http://localhost:84/mycms/public/css/index.css">
It's working fine.
Then I'm trying the laravel way with this https://stackoverflow.com/a/16565640/6354277 . And i change it to this
<link rel="stylesheet" href="{{ URL::asset(css/index.css') }}">
It Seems i can't found the css file. How can i fix it ?
You may try this.
My css file is in public/css/sample.css
It works fine
<link href="{{ asset('css/sample.css') }}" rel="stylesheet" >

Resources