twan
twan

Reputation: 2659

Laravel yield is empty

I have a master blade file that includes some other blade files and yields content of a blade file called home which I extend on this master blade, I can click on master from my home blade in phpstorm and it takes me to the correct file, so they must be connected correctly.

The problem is the contents are not loaded, it just loads the head/header and footer but nothing from my home.blade.

My master.blade.php:

<!doctype html>
<html lang="en">
@include('partials.head')
<body>

@include('partials.header')
@yield('content')
@include('partials.footer')
</body>
</html>

In my home.blade.php

@extends('master')
@section('title', 'Home')
@section('content')
<main id="content">
    test
</main>
@endsection

It loads everything correctly except the content section. What am I doing wrong?

Only route I got:

Route::get('/', function () {
    return view('master');
});

Upvotes: 1

Views: 186

Answers (1)

Sujith Sandeep
Sujith Sandeep

Reputation: 1249

You have to change the view of the route,

Route::get('/', function () {
    return view('home');
});

Upvotes: 4

Related Questions