Home > Back-end >  Laravel 8.0, problems with @yield('content') make duplicity of the content section in othe
Laravel 8.0, problems with @yield('content') make duplicity of the content section in othe

Time:01-25

I have a newly started project in Laravel 8.0, and I have a problem with views.

I have the following master.blade.

<html>
    <head>
        <title>App Name - @yield('title')</title>
    </head>
    <body>

        <div >
           @yield('content')
        </div>
         <footer >
        @include('layouts.footer')
    </footer>
    </body>
</html>

I then have a view that extends that master blade:

@extends('layouts.app')
@extends('layouts.master')
@section('content')

HELLO

@stop

The problem is, when rendering the view, the information is duplicated. Appears once inside the container div so the @yield works, but is re-rendered in another div outside the container (main ).

Let's see if someone can help me with the problem.

Thank you very much in advance.

CodePudding user response:

@extends('layouts.master')
@section('content')

HELLO

@endsection

you extends two time

CodePudding user response:

You must add one extends, edit the code and do the code below

@extends('layouts.master')
@section('content','your title')

HELLO

@endsection

that the right way to get the view.

  •  Tags:  
  • Related