Answer the question
In order to leave comments, you need to log in
What are the best practices for creating separate titles for each page in Laravel?
Hello.
My first Laravel project is nearing completion :) when suddenly I remembered that we need custom title (and other meta tags) for each page.
But the problem is that the
entire head is placed in layouts.main, and the content is created by a dozen different controllers (this is the specifics of the project) whose methods return views that inherit this same layouts.main - and it turns out that I cannot set a variable from controllers, say, $title, in layouts.main
Or can I?
How is this generally done in the mind usually in Laravel?
Thank you.
Answer the question
In order to leave comments, you need to log in
I did this
in the views, the title variable is passed
extends('layouts.main', ['title' => 'Тайтл'])
@section('content')
//контент
@endsection
<title>
@isset($title)
{{ $title }} |
@endisset
{{ config('app.name') }}
</title>
Just take any package and do not invent bicycles. An example of what you can connect without racking your brains - https://github.com/eusonlito/laravel-Meta
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question