tgif's avatar
Level 4

adding page specific css compilation with Blade

Hi, guys. My layout blade page links all the base css files and @includes the navigation code. The content of each page have separate addendum css compilations. How would you add these css files when the content is @yield(ed) in the body?

0 likes
2 replies
jasonlewis's avatar
Level 1

If you're using Blade templating you can add a yield('assets') in your <head>.

<head>
    <title></title>
    
    <!-- all your other assets here -->

    @yield('assets')
</head>

Then in your pages you can just include them.

@extends('layout')

@section('assets')
    <link rel="stylesheet" href="path/to/asset.css">
@endsection

@section('content')
    This is the content.
@endsection

Something like that.

4 likes

Please or to participate in this conversation.