将元标记添加到laravel页面 [英] Add meta tags to laravel page
本文介绍了将元标记添加到laravel页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试向Laravel页面添加描述和关键字.
I'm trying to add description and keywords to my Laravel pages.
这种方式有效吗?还是有什么问题?
Is this way working? Or there is something wrong?
@section('title')
{{trans('strings.About')}}
@stop
@section('description', 'Share text and photos with your friends and have fun')
@section('keywords', 'sharing, sharing text, text, sharing photo, photo,')
@section('robots', 'index, follow')
@section('revisit-after', 'content="3 days')
推荐答案
您要扩展使用所有这些sections
的另一个模板吗?他们将无法独立工作,需要在另一个模板中填充占位符.
Are you extending another template that uses all these sections
? They won't work on their own, they need to populate a placeholder in another template.
应该是这样的:
<!-- layouts.master -->
<html>
<head>
<title>App Name - @yield('title')</title>
<meta name="description" content="@yield('description')">
<meta name="keywords" content="@yield('keywords')">
<!-- etc -->
</head>
<body>
...
</body>
</html>
然后您的模板应扩展其他模板.
And then your template should extend the other template.
@extends('layouts.master')
@section('title')
{{trans('strings.About')}}
@stop
@section('description', 'Share text and photos with your friends and have fun')
@section('keywords', 'sharing, sharing text, text, sharing photo, photo,')
@section('robots', 'index, follow')
@section('revisit-after', 'content="3 days')
至少,这就是我阅读其文档的方式: https://laravel.com/docs/5.2 /blade
At least, that is how I read their documentation: https://laravel.com/docs/5.2/blade
这篇关于将元标记添加到laravel页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文