问题
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