Laravel 5.1 linking style sheet not working

1.3k views Asked by At

I am probably missing something very simple but, when I link my style sheet I get:

<link media="all" type="text/css" rel="stylesheet" href="http://laravel.dev:8000/public/css/masterCss.css">

showing on the webpage rather then linking to my css file.

My Html looks like:

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <title>The Nub Life</title>

    {{ Html::style('/public/css/masterCss.css') }}

</head>
<body>

@yield('content')

</body>
</html>

Why is this happening and how can I fix it?

2

There are 2 answers

0
Salar On

the stylesheet href url, should not contain the word public. this is how you can generate url for your css asset files

<link media="all" type="text/css" rel="stylesheet" href="{{ URL::asset('css/masterCss.css') }}">
0
KhanShaheb On

Suppose you have a .css file in your public/your_project_name/css/style.css

Simply write

<link href="{{ URL::asset('your_project_name/css/style.css') }}" rel="stylesheet">