如何在 Laravel 上链接网站图标

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/27563580/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-08 16:50:09  来源:igfitidea点击:

How to link favicon icon at Laravel

laravelhyperlinkfavicon

提问by Ahmad Sharif

We know how to link HTML images and CSS files according to the following code.

我们知道如何根据以下代码链接 HTML 图像和 CSS 文件。

{{ HTML::image('images/example.jpeg', 'Example Image') }}
{{ HTML::style('css/main.css') }}

But, how to link the favicon icon at Laravel as we can not do like a static HTML file?

但是,我们不能像静态 HTML 文件那样链接 Laravel 上的 favicon 图标?

回答by Ahmad Sharif

For Laravel 5.xx

对于 Laravel 5.xx

We can link favicon icon and css file in the following way. In Laravel application put your favicon icon and css file under the public folder. In my case, I put them public/css folder.

我们可以通过以下方式链接 favicon 图标和 css 文件。在 Laravel 应用程序中,将您的网站图标和 css 文件放在 public 文件夹下。就我而言,我将它们放在 public/css 文件夹中。

<link rel="shortcut icon" href="{{ asset('img/favicon.png') }}">
<link href="{{ asset('css/style.css') }}" rel="stylesheet">

For Laravel 6.00

对于 Laravel 6.00

<link rel="icon" href="{{ URL::asset('/css/favicon.jpg') }}" type="image/x-icon"/>
<link rel="stylesheet" type="text/css" href="{{ URL::asset('/css/app.css')  }}">

回答by s-hunter

In laravel 5, the favicon.ico is in public/favicon.icoTo change the favicon, just have to replace public/favicon.icowith yours.

在 Laravel 5 中,favicon.ico 位于public/favicon.ico要更改 favicon,只需将public/favicon.ico替换为您的。

回答by Kushagra Saxena

<link rel="shortcut icon" href="{{ asset('img/favicon.ico') }}">

In blade we can use the assets like asset('img/favicon.ico') but they should be in {{...}} instead of {{{...}}}

在刀片中,我们可以使用像 asset('img/favicon.ico') 这样的资产,但它们应该在 {{...}} 而不是 {{{...}}}

回答by vozaldi

If you're using LaravelCollective

如果你使用LaravelCollective

{{ Html::favicon( '/assets/images/favicon.ico' ) }}

You can see whole Htmlmethod in /vendor/laravelcollective/html/src/HtmlBuilder

你可以看到整个Html方法/vendor/laravelcollective/html/src/HtmlBuilder

Edit:Installation guide in here.

编辑:此处的安装指南。

回答by Koushik Das

There's also other way to show it.

还有其他方式来展示它。

    <link rel="shortcut icon" type="image/x-icon" href="{{ URL::to('fav icon link') }}"/>

Hope this helps.

希望这可以帮助。

回答by Boss COTIGA

Default .ico favicon and best quality for modern browser .png favicon placed in /public/

默认 .ico favicon 和现代浏览器的最佳质量 .png favicon 放置在 /public/

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

回答by Trainnee WCL

it's work!!!!

这是工作!!!!

 <link rel="shortcut icon" href="<?php echo asset('assets/image/favicon-32x32.png'); ?>">

hope this helps

希望这可以帮助

回答by sainath kishore

for image inside public use: title tag your title

对于公共使用的图像:标题标记您的标题

followed

跟随

link rel='shortcut icon' href='public/favicon.ico' type='image/x-icon'

link rel='shortcut icon' href='public/favicon.ico' type='image/x-icon'

for image in other location inside public:

对于公共内部其他位置的图像:

title tag your title

标题标签你的标题

followed by

其次是

link rel='shortcut icon' href='public/pathtoicon/favicon.ico' type='image/x-icon'

link rel='shortcut icon' href='public/pathtoicon/favicon.ico' type='image/x-icon'

Hope this will be helpful

希望这会有所帮助