简体   繁体   English

如何让我的图标工作?

[英]How do I get my favicon to work?

I'm creating a website and I have a favicon that I want to use for it. 我正在创建一个网站,我有一个我想用它的图标。 It is in the same folder as my index.html file. 它与我的index.html文件位于同一文件夹中。 I was wondering how to actually use the favicon for my website. 我想知道如何在我的网站上实际使用favicon。 I did set it up so that it is 16 by 16 pixels and has a .ico extension. 我确实将它设置为16 x 16像素并具有.ico扩展名。 By the way I am hosting my website locally for testing purposes using MAMP. 顺便说一下,我在本地托管我的网站,以便使用MAMP进行测试。

Here is a picture of my folder with the favicon in it: 这是我的文件夹中包含favicon的图片: 在此输入图像描述

I was wondering what I have to do with it to make it work. 我想知道我要做些什么才能让它发挥作用。

Here is my index.html file: 这是我的index.html文件:

<html>
    <head>
        <meta charset="UTF-8">
        <title>LFX Music</title>
    </head>

    <body>
    </body>
</html>

Do I need to put the favicon code inside every file that has an html head tag? 我是否需要将favicon代码放在​​每个具有html头标记的文件中? If so do I put the same code inside every file even if they are in different folders? 如果是这样,即使它们位于不同的文件夹中,我也会在每个文件中放入相同的代码? Say I wanted to put it in the about.html file that is in the child folder, "about", then what would the code be? 假设我想将它放在子文件夹中的about.html文件中,“about”,那么代码是什么?

Also while I'm at it, even though it doesn't really matter, what is good folder naming etiquette? 虽然我很喜欢,但即使它并不重要,什么是好文件夹命名礼仪? For instance I have the "_images" folder and inside that I have a folder called "favicons". 例如,我有“_images”文件夹,里面有一个名为“favicons”的文件夹。 Should I call the folder "favicons", "_favicons", or "__favicons" to keep up with the way I'm currently structuring my assets folders? 我应该调用文件夹“favicons”,“_ favicons”或“__favicons”来跟上我目前构建资产文件夹的方式吗?

Thank you so much! 非常感谢!

<html>
  <head>
    <meta charset="UTF-8">
    <title>LFX Music</title>
    <link rel="shortcut icon" href="favicon.ico">
  </head>

  <body>
  </body>
</html>

and about folders, name them however you like. 关于文件夹,无论如何都要命名。

I have setup eg 我已经设置了例如

images
css
js

...

As long is the file is named FAVICON.ICO and in the root, and it actually IS an .ICO file, built to the correct specs, it should work without having to add a single thing to your code. 只要该文件名为FAVICON.ICO并且在根目录中,它实际上是一个.ICO文件,根据正确的规范构建,它应该可以工作,而无需在代码中添加任何东西。

And by "correct specs", I mean, don't just take a PNG and rename it and expect it to work. 而且,通过“正确的规格”,我的意思是,不要只是采用PNG并将其重命名并期望它能够正常工作。 An .ICO is actually it's own specific format. .ICO实际上是它自己的特定格式。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM