Laravel 5.2 - Metatag canonical Url

£可爱£侵袭症+ 提交于 2019-12-11 06:28:57

问题


i'm tryng to integrate metatags in my layout 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:

Class 'echoURL' not found

How can i get Current URL ? maybe with blade? i tryed to search some solution with blade but i did not find nothing.

Thank you for your help!


回答1:


You forgot to put space between echo and URL facade:

<?php echo URL::current(); ?>

Also, in Blade you usually want to avoid using <?php ?>:

{{ URL::current() }}



回答2:


Is another solution if you use this code:

put this in app layout, between <head></head> section.

<link rel="canonical" href="{{ url(Request::url()) }}" />

and you get current URL address




回答3:


Laravel 5.7

<link rel="canonical" href="{{ url()->current() }}" />



回答4:


use following code instead

{{ URL::current() }}

"avoid using of tags"



来源:https://stackoverflow.com/questions/40725158/laravel-5-2-metatag-canonical-url

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!