如何在 Laravel 5.4 中为 404 错误页面添加元标记
How to add Meta tags for 404 error page in Laravel 5.4
我想更新我的 404 error page
的 meta tags
,即我的 Laravel 5.4 网站的 404.blade.php。
404.blade.php 页面位于路径:\resources\views\errors
我构建的所有其他页面都有我可以轻松传递的控制器 meta title, meta description and meta keyword
并在我的前端设计通用文件中使用它们,如下所示。
<title>
@if(isset($title))
{{ $title }}
@endif
</title>
@if(isset($meta_description))
<meta name="description" content="{{ $meta_description }}">
@endif
@if(isset($meta_keyword))
<meta name="keywords" content="{{ $meta_keyword }}">
@endif
但是在 404 错误页面的情况下,我没有任何可以传递其元标记的控制器。所以不知道如何为 404 错误页面添加元标记。
请帮帮我!
<title>
@if(isset($title))
{{ $title }}
@endif
</title>
@if(!isset($meta_description))
$meta_description = '404';
@endif
<meta name="description" content="{{ $meta_description }}">
@if(!isset($meta_keyword))
$meta_description = '404';
@endif
<meta name="keywords" content="{{ $meta_keyword }}">
你可以试试这个。
我添加了另一个设计布局错误-design.blade.php 专门针对 404 错误页面,并在那里添加了所有 404 元标记。现在它工作正常。
我想更新我的 404 error page
的 meta tags
,即我的 Laravel 5.4 网站的 404.blade.php。
404.blade.php 页面位于路径:\resources\views\errors
我构建的所有其他页面都有我可以轻松传递的控制器 meta title, meta description and meta keyword
并在我的前端设计通用文件中使用它们,如下所示。
<title>
@if(isset($title))
{{ $title }}
@endif
</title>
@if(isset($meta_description))
<meta name="description" content="{{ $meta_description }}">
@endif
@if(isset($meta_keyword))
<meta name="keywords" content="{{ $meta_keyword }}">
@endif
但是在 404 错误页面的情况下,我没有任何可以传递其元标记的控制器。所以不知道如何为 404 错误页面添加元标记。
请帮帮我!
<title>
@if(isset($title))
{{ $title }}
@endif
</title>
@if(!isset($meta_description))
$meta_description = '404';
@endif
<meta name="description" content="{{ $meta_description }}">
@if(!isset($meta_keyword))
$meta_description = '404';
@endif
<meta name="keywords" content="{{ $meta_keyword }}">
你可以试试这个。
我添加了另一个设计布局错误-design.blade.php 专门针对 404 错误页面,并在那里添加了所有 404 元标记。现在它工作正常。