Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Link in laravel blade template

I'm struggling to create link in blade template in Laravel. I will pass the URL in template from environment variable.

The output suppose to be like.

<a href="https://google.com">Visit Google</a>

I am trying sth like this but with no luck.

<a href="{{env('APP_URL')}}">Visit my site</a>

Laravel Framework 5.5.19

Thank you

like image 839
Vojta Avatar asked Nov 04 '17 19:11

Vojta


People also ask

Can we write PHP code in blade template Laravel?

Blade is the simple, yet powerful templating engine that is included with Laravel. Unlike some PHP templating engines, Blade does not restrict you from using plain PHP code in your templates.

What is Uri in Laravel?

Routing in Laravel allows you to route all your application requests to their appropriate controller. The main and primary routes in Laravel acknowledge and accept a URI (Uniform Resource Identifier) along with a closure, given that it should have to be a simple and expressive way of routing.

What is the advantage of Laravel blade template?

The blade templates are stored in the /resources/view directory. The main advantage of using the blade template is that we can create the master template, which can be extended by other files.


1 Answers

Use the Laravel helper url()

For a link to the home page: <a href="{{ url('/') }}">Visit Google</a>

From Laravel docs: https://laravel.com/docs/5.5/helpers#method-url

like image 113
kerrin Avatar answered Oct 14 '22 07:10

kerrin