Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Setting a single favicon for the entire website

Tags:

html

favicon

Currently I'm using this bit of code to add a favicon to a website:

<link rel="shortcut icon" href="https://www.mysite.co.uk/images/favicon/favicon1.ico" />

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.

UPDATE:

Chrome searches for a favicon.ico file in the root directory.

Firefox needs this on each page:

<link rel="icon" type="image/png" href="/favicon.png" />
like image 923
Switchfire Avatar asked Jun 07 '13 08:06

Switchfire


People also ask

How do I add a favicon to an entire website?

To add a favicon to your website, either save your favicon image to the root directory of your webserver, or create a folder in the root directory called images, and save your favicon image in this folder. A common name for a favicon image is "favicon.ico".

Can a website have multiple favicons?

<? php echo '<link rel="shortcut icon" href="http://www.yoursite.com/favicon.ico?t=' . time() . '" />; ?>


1 Answers

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.

Use <?include "header.php" ?> on all pages where your header.php includes all the code that is common to all pages

It could be something like:

<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

See more about include here: http://php.net/manual/en/function.include.php

EDIT: 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.

like image 185
2 revs Avatar answered Sep 20 '22 15:09

2 revs