Reputation: 57
In my laravel website all pages having same title meta but how to make different title for each page please tell me.
this is my code for dynamic showing in all the pages
<title>{{setting('site.title')}} | {{setting('site.description')}} @if(isset($data->title)) {{$data->title}} @endif</title>
file name is layouts/app.blade.php
Upvotes: 4
Views: 12787
Reputation: 210
Inside your app.blade.php
,
<head>
@yield('title')
... // other scripts
</head>
For other pages which user app.blade.php you can use it like after extending app.blade.php
:
@section('title')
<title> Your Page Title Here </title>
@endsection`
Hope it helps. happy coding.
Upvotes: 2
Reputation: 312
in your controller
public function aboutUs()
{
//page title
$title = 'Project | About Us';
return view('project.about_us', compact('title'));
}
for your view page
<title>{{ $title }}</title>
Upvotes: 1
Reputation: 799
Simply inside your app.blade.php Put this: @yield('title')
In other pages just extend the layout and put the new title at the this section
@extends('layoutWhateverYouNamedIt')
@section('title') Type your title here @endsection
Upvotes: 2
Reputation: 151
Inside your app.blade.php
, in the head section.
change:
<title>{{ config('app.name', 'Laravel') }}</title>
to:
<title>@yield('title')</title>
You can choose any name/title that seems fitting.
For other views.blade.php
pages,(extending app.blade.php
) you can add a title this way:
@section('title','My Title')
this comes after @extends('layouts.app')
Upvotes: 15
Reputation: 1301
You can specify different title for different views.
In you common header file make your title like this:
<title>@yield('page_title', 'Default Title')</title>
Then in your view file change the title to whatever you want it to be set in following way:
@section('page_title')
{{ "Your Title" }}
@endsection
Upvotes: 13