I recently installed Laravel 5.2 and i´ve been experiencing some problems loading css and js files from the project public folder.
I have all my views on the resources folder and my asset files on the public folder, i tried installing html collective but is not working.
Could someone please help me link the css and js files, so they load.
This is my view:
<link href="assets/css/style.css" rel="stylesheet">
<link rel="stylesheet" href="/css/app.css" />
You can use the asset helper:
$url = asset('img/photo.jpg');
Cf docs: https://laravel.com/docs/5.2/helpers#method-asset
Related
I'm trying to add the favicon to a Inertiajs app but it doesnt work.
I'm using laravel 9 with inertiajs, vue3 with vite and tailwind.
The route is fine "Public/Images"
Do any one understand why?
<link rel="icon" type="svg+xml" sizes="32x32" href="../../public/Images/Favicon.svg" />
laravel web folder is at public so all you need to do is reference it as the TLD,
in your resources/views/app.blade.php
you can directly reference a directory inside public, so instead of ../../public/Images/Favicon.svg it should be /Images/Favicon.svg
<link rel="icon" href="/Images/Favicon.svg" />
When I ran it on my system in my local server it was working fine but when I deployed it on GitHub pages Deployment, GitHub doesn't seem to load my CSS and the CSS was not applied on my file.
repository link: https://github.com/pawangupta5050/Facebook-Login-Clone
live-website link on GitHub pages :https://pawangupta5050.github.io/Facebook-Login-Clone/
You should consider using this...
<link rel="stylesheet" href="./assets/index.76858414.css">
Instead of this...
<link rel="stylesheet" href="/assets/index.76858414.css">
You can read more about HTML file paths here.
hello Laravel developers!
I am stuck with Laravel assets URLs.
<link href="/css/app.css" rel="stylesheet">
this link works fine on localhost.
But why i need to add "public" when i upload it to server like
<link href="/public/css/app.css" rel="stylesheet">
I moved app/public/index.php to app/index.php and make changes in server.php and index.php accordingly. Rest is the working fine. issue is only with assets urls.
Similarly, the class
.edu-home-hero-area {
background: url(/assets/images/curve.webp) !important;
}
works fine on localhost but when i upload it, it does not work i need to change it to
.edu-home-hero-area {
background: url(/public/assets/images/curve.webp) !important;
}
please have a look
https://pdaofficial.com/
any help would be appreciated
I'm not sure if i understand your question completely but you should not be moving public folder files some where else. why not reference your css or js assets using asset function. It will directly point to public folder and look for build.css inside css folder.
<link type="text/css" rel="stylesheet" href="{{ asset('css/build.css') }}">
I'm new to Laravel Breeze and tailwind.
After successfully installed Laravel Breeze and looking at /login page source, I couldn't match the source code and actual page source and would like to know what's going on.
In app.blade.php or guest.blade.app there are the following lines.
<!-- Styles -->
<link rel="stylesheet" href="{{ asset('css/app.css') }}">
<!-- Scripts -->
<script src="{{ asset('js/app.js') }}" defer></script>
But when viewing login page source, it has
<!-- Styles -->
<style>
/*! normalize.css v8.0.1 | MIT License | github.com/necolas/normalize.css */html{line-height:1.15;-webkit-text-size-adjust:100%}body{margin:0}a{background-color:transparent} ...
</style>
<style>
body {
font-family: 'Nunito';
}
</style>
And no javascript is loaded.
I'm expecting to see just the link to public/css/app.css and public/js/app.js but no such thing here.
So if anyone can explain how Laravel Breeze works regarding to including css and js
and how I can extend tailwind css to other pages and use js in other pages, I'd really appreciate.
You need to compile the assets installed with Breeze. To do so, just run the following commands on your project directory:
npm install
npm run dev
If you check the Public folder on your Laravel app, you should see the CSS and JS compiled. Refresh the page, and the style should look OK.
Documentation reference:
https://laravel.com/docs/8.x/starter-kits#laravel-breeze-installation
I have installed a Laravel 5.2 to run an existing project from my group mates but in my laptop, the project will only read inline CSS, it cannot read Linked CSS, What seems to be the problem?
you should use helper
url('path/to/css/file/in/public/folder')
First, put your assets in the public folder
Then you can use:
<link href="{{ url('path/file.css')}}" rel="stylesheet" type="text/css" />