Laravel 5: adding custom styles / scripts
This is a stupid question and I have looked for similar answers and found some, however they are a little more specific than what I am asking.
Suppose I want to add a custom file, styles.css
or scripts.js
can I create a css / js folder in the folder resources/views
and then call them in my blade.php files as usual in an HTML file when you are not using Laravel?
Example: <link type="text/css" rel="stylesheet" href="css/styles.css">
Or is there any other approach to this in Laravel?
source to share
Place your css files in a folder public
likepublic/css/styles.css
Use the function asset()
to add css
, javascript
or images
to your template video.
For style sheets
<link href="{{ asset('css/styles.css') }}" rel="stylesheet" type="text/css" >
or
<link href="{{ URL::asset('css/styles.css') }}" rel="stylesheet" type="text/css" >
For Javascript
<script type="text/javascript" src="{{ asset('js/scripts.js') }}"></script>
or
<script type="text/javascript" src="{{ URL::asset('js/scripts.js') }}"></script>
You might also be interested in taking a look at Laravel Elixir for handling your stylesheets and javascript.
source to share
put your style.css file inside a css folder named: / css AND your js file inside a js folder named: / jsput below the code in your html file.
Your css files
<link rel="stylesheet" href="{{ URL::asset('css/yourstylesheet.css') }}" />
And js files
<script type="text/javascript" src="{{ URL::asset('js/jquery.min.js') }}"></script>
source to share