Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

atif123's avatar

How to add favicon in laravel

not working

0 likes
13 replies
bobbybouwmann's avatar
Level 88

In general you need to do something like this in your <head> </head> tags in HTML

<link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png">
<link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png">
<link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png">
<link rel="manifest" href="/site.webmanifest">

You can use this site to generate your favicons: https://favicon.io/

Also, "not working" is not really helpful if you have a question... Please be more specific. Tell us what you tried and what part is not working ;)

18 likes
atif123's avatar

i have included code but why my code is removed

bobbybouwmann's avatar

I don't know... Anyway did you get it all working now?

1 like
Snapey's avatar

Please format your code by putting 3 backticks ``` on a line before and after each code block

1 like
alev's avatar

You should put it into the public directory and reference to it with following code:

<link rel="icon" href="{{ URL::asset('favicon.ico') }}" type="image/x-icon"/>

3 likes
ajsmith_codes's avatar

This one worked for me. I couldn't get Snapey's suggestion to work on the server.

entoniperez's avatar

In Laravel 8, I must to add my favicon in a folder inside /public root directory. Then I use this tag in blade view:

<link rel="shortcut icon" type="image/x-icon" href="{{ asset('img/favicon.ico') }}">
1 like
webrobert's avatar

@entoniperez In general, best practices is always put favicon-related files in the root directory (site/public). Not nested within another directory.

1 like
entoniperez's avatar

@webrobert For sure you are right, but it doesn't work if I put the favicon in the root directory. I don't know why...

imingame's avatar

My favico not show with this code inside my master.blasde.php:

i'm using laravel module nwidart
aiMeta's avatar

This worked for me:

    <!-- Favicon -->
    <link rel="shortcut icon" type="image/x-icon" href="{{ asset('favicon.ico') }}">

with *.ico placed in public (not in folder within public)

Thank you everyone for the info above...

Please or to participate in this conversation.