shani singh
Posted on May 30, 2021
As Laravel use Blade template engine, many time we have to use the page title to be displayed dynamically,
Let's Consider you have a master layout for your app.
which have a structure something like
<html>
<head>
<title>App Name - @yield('title')</title>
</head>
<body>
@section('sidebar')
This is the master sidebar.
@show
<div class="container">
@yield('content')
</div>
</body>
Here in Master Layout the code for title is.
<title>App Name - @yield('title')</title>
Then You load the Content Page which looks like.
@extends('layouts.master')
@section('title') {{'Page Title Goes Here'}} @endsection
@section('content')
<p>This is my body content.</p>
@endsection
Here in Content file the code for title is.
@section('title') {{'Page Title Goes Here'}} @endsection
You can watch the video below for live coding.
Thank You for Reading
Reach Out To me.
Twitter
Instagram
TechToolIndia
💖 💪 🙅 🚩
shani singh
Posted on May 30, 2021
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.
Related
laravel How to use diffInDays with filters in Laravel | Tutorial | Quick Win Wednesday #QWW
November 20, 2024