Laravel 5.2 - Metatag 规范 URL
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/40725158/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Laravel 5.2 - Metatag canonical Url
提问by Diego Cespedes
i'm tryng to integrate metatags in my layout laravel,
我正在尝试将元标签集成到我的布局 Laravel 中,
app.layouts
应用程序布局
<title>SiRegala.it - @yield('title')</title>
<meta name="description" content="@yield('description')"/>
<link rel="canonical" href="@yield('canonical')"/>
view
看法
@section('title')
Homepage
@stop
@section('canonical')
<?php echoURL::current(); ?>
@stop
i'm tryng to get current url of my view, but actually i get this error:
我正在尝试获取我视图的当前 url,但实际上我收到了这个错误:
Class 'echoURL' not found
找不到类“echoURL”
How can i get Current URL ? maybe with blade? i tryed to search some solution with blade but i did not find nothing.
如何获取当前 URL?也许用刀片?我试图用刀片搜索一些解决方案,但我什么也没找到。
Thank you for your help!
感谢您的帮助!
回答by Alexey Mezenin
You forgot to put space between echo
and URL
facade:
你忘了在echo
和URL
立面之间放置空间:
<?php echo URL::current(); ?>
Also, in Blade you usually want to avoid using <?php ?>
:
此外,在 Blade 中,您通常希望避免使用<?php ?>
:
{{ URL::current() }}
回答by Farid Movsumov
Laravel 5.7
Laravel 5.7
<link rel="canonical" href="{{ url()->current() }}" />
回答by Johnny
Is another solution if you use this code:
如果您使用此代码,则是另一种解决方案:
put this in app layout, between <head></head>
section.
把它放在应用程序布局中,在<head></head>
部分之间。
<link rel="canonical" href="{{ url(Request::url()) }}" />
and you get current URL address
你会得到当前的 URL 地址
回答by Kundan roy
use following code instead
改用以下代码
{{ URL::current() }}
{{ URL::current() }}
"avoid using of tags"
“避免使用标签”