Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Amalmax's avatar

How to link External CSS file to Laravel Blade file

using Laravel 7 and I have following welcome.blade.php file

@extends('layouts.app')

@section('content')
@include('pages.main')

@include('partials._footer')

@endsection

my main.blade.php file is like

<main role="main">
<div class="album py-5 bg-light">
  <div class="container ">
    <div class="row">
      <div class="col-md-4">
          <a href="#" class="thumbnail">
           <div class="card border-dark mb-3 rounded-0" style="max-width: 25rem;">
               <div class="card-header bg-transparent border-dark rounded-0">Header</div>
  </div>
  </div>
</div>

and I need add some css file name album.css to main.blade.php file in side the pages folder and css file is in the public/css folder. then how could I add my css file to main blade file as external file?

0 likes
11 replies
jame254's avatar

does this apply when i have different stylesheet for each page?

Amalmax's avatar

working for this codes


<link rel="stylesheet" href="{{ URL::asset('css/main.css') }}" />
anjanesh's avatar

Most of the answers refer to mix. Laravel 9 has replaced mix with vite. Vite is just the tooling that replaced mix right ?

This would still work if we were to remove mix altogether and use vite ?

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

What is the vite equivalent of mix('css/main.css') ?

codexknight7's avatar

Hi everyone, could I ask the same question again? After trying all the possible and impossible ways, I could not make my CSS work. The file is not found. 404 is returned. I have a very simple Blog application.

-A master layout in views, with includes of additional layouts:

\blog\resources\views\layouts\master.blade.php

-I load here my css file like this, in section:

link href="{{ asset('css/blog.css') }}" rel="stylesheet"

-The CSS file is here:

resources\css\blog.css

I tried with :

link href="css/blog.css'" rel="stylesheet"

link href="/css/blog.css'" rel="stylesheet"

link href="../../css/blog.css'" rel="stylesheet"

And nothing works. Always 404 Not Found.

2 likes
Sinnbeck's avatar

@codexknight7 if the answer isn't already in this thread please make a new one. This one is already solved

AddWebContribution's avatar

Please use path like this href="{{ asset('assets/css/custom.css') }}"

and put your css in public/assets/css folder

Please or to participate in this conversation.