将元标记添加到 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/刀片
At least, that is how I read their documentation: https://laravel.com/docs/5.2/blade
这篇关于将元标记添加到 Laravel 页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文