Laravel Blade Section Directive Example

  1867 views   1 year ago Laravel

Laravel provides many built-in directives. This directives helps in adding PHP codes and functionalities easily. One of these directives is @section and @yield directives.

In this article, I will show you how to use @section and @yield directives in Laravel blade. All web application uses common layout file which extends to all views.

In Laravel application, main Layout file contains @yield directives with name inside it. Here is the common layout view file at resources/views/layouts/app.blade.php.

<!DOCTYPE html>
        <title>@yield('title') - Laravel</title>
        <div class="container">

We have defined main layout view. Now we will extends this layout in any blade view. When we will add @section directive in blade view, It will be inserted to master view's @yield directive.


@section('title', 'Page Title')


    <p>This is appended to the master sidebar.</p>

    <p>This is my body content.</p>

I hope it will help you on your web developement. Thanks for giving time in reading article.

Author : Harsukh Makwana
Harsukh Makwana

Hi, My name is Harsukh Makwana. i have been work with many programming language like php, python, javascript, node, react, anguler, etc.. since last 5 year. if you have any issue or want me hire then contact me on [email protected]