Skip to content
Advertisement

Laravel: Layouts.master not found

I built the demosite in Laravel, but I got the following error:

ErrorException in FileViewFinder.php line 137: View [layouts.master] not found.(View: /var/www/html/project/laravel/laravel/resources/views/page.blade.php)

The master.blade.php is next to the page.blade.php, both are in resources/views

master.blade.php

<html>
    <head>
        <title>@yield('title')</title>
    </head>
    <body>
        @section('sidebar')
        This is the master sidebar.
        @show
        <div class="container">
        @section('content')
        </div>
    </body>
</html>

page.blade.php

@extends('layouts.master')
@yield('title', 'Page Title')
@section('sidebar')
@parent
<p>This is appended to the master sidebar.</p>
@endsection
@section('content')
<h2>{{$name}}</h2>
<p>This is my body content.</p>
@endsection

What goes wrong? I working from this tutorial.

Advertisement

Answer

Try

@extends('master')

They are both at the views root you said. Or create a directory called layouts and place master.blade.php inside.

Updates In your master.blade.php where you want your content to be “injected”, do:

@yield('content')
//remove @section('content') because your master does not extends any other layout

The exact same way you did with @yield('title').

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement