Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Laravel: What's the advantage of using the asset method in blade pages?

In some laravel examples I've seen assets being called like this:

<link rel="icon" type="image/png" href="{{ asset('icons/favicon-32x32.png') }}" sizes="32x32">

What is the advantage of using that method as opposed to doing this?

<link rel="icon" type="image/png" href="icons/favicon-32x32.png" sizes="32x32">
like image 659
OMA Avatar asked Mar 09 '16 15:03

OMA


1 Answers

If you do the latter, the URLs will not work when you're on any URL that includes a forward slash. E.g. not using asset will appear to work fine if you're on the homepage, but if you were on /search/results or whatever, the URLs won't be correct (as it'll be looking for /search/icons/favicon-32x32.png).

like image 110
alexrussell Avatar answered Oct 27 '22 01:10

alexrussell