为整个网站设置一个favicon [英] Setting a single favicon for the entire website
问题描述
Currently I'm using this bit of code to add a favicon to a website:
快捷图标href =https://www.mysite.co.uk/images/favicon/favicon1.ico/>
<link rel="shortcut icon" href="https://www.mysite.co.uk/images/favicon/favicon1.ico" />
但是,这些代码必须添加到每个HTML页面。有谁知道如何设置全局图标?
However, this code must be added to each HTML page. Does anyone know how to set a global favicon?
我看到的每个地方都告诉我必须将其添加到每个页面。
Everywhere I've looked tells me I must add it to each page.
更新:
Chrome在根目录中搜索favicon.ico文件。
Chrome searches for a favicon.ico file in the root directory.
Firefox需要在每个页面上显示这些内容:
Firefox needs this on each page:
<link rel="icon" type="image/png" href="/favicon.png" />
推荐答案
包括favicon)在每个页面上保持一致,因此您只需编辑一个文件而不是大量文件。
For future reference use php to include the header information (including the favicon) that stays consistent on each page so that you only have to edit one file instead of a large number of files.
使用< ;?includeheader.php?>
在您的header.php包含所有页面共有的所有代码的所有页面上
Use <?include "header.php" ?>
on all pages where your header.php includes all the code that is common to all pages
可能是这样的:
<link rel="stylesheet" href="screen.css" type="text/css" media="screen" />
<script src="../quirksmode.js"></script>
<link rel="icon" href="/favicon.ico" type="image/x-icon" />
以及所有其他需要包含在所有页面中的代码
and all the other code that needs to be included on all the pages
了解更多关于此处的信息:
http://php.net/ manual / en / function.include.php
See more about include here: http://php.net/manual/en/function.include.php
编辑:
现在您可以在编辑器中打开所有文件,如记事本++,然后执行查找并替换以替换\r\\\
中的所有匹配项,其中\ r \ n是扩展搜索模式中窗口的换行符。
Notepad ++可以选择在所有打开的文件中进行查找和替换。
For now you could open all files in an editor like notepad++ and do a find and replace to replace all occurrences of with \r\n where \r\n is the newline character for windows in the extended search mode. Notepad++ has the option to do a find and replace in all open files.
这篇关于为整个网站设置一个favicon的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!