Table of contents
In this post, you will learn about the Laravel 9 blade section with an example. Laravel blade
@section is a directive that will able us to inject content layout from the extended blade. The content of the section will show the layout using the
Now let's create a folder
resources/views and then create a file
<!DOCTYPE html> <html> <head> <title>@yield('title') - App Name</title> </head> <body> <div class="container"> @yield('content') </div> </body> </html>
Then next let's create our child blade inside
resources/views usually, it is home, contact, page, etc.
As you can see we use
@section directives. For more about Laravel Blades kindly visit their documentation here: https://laravel.com/docs/9.x/blade.
@extends('layouts.master') @section('title', 'Page Title') @section('content') <p>This is your content body.</p> @endsection
I hope it helps. If you want to know about Laravel blade templating you can visit our previous tutorial here.