Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

This question is not technical but rather "ideological" - where in WP should favicon be stored (in "correct" way)? Should it be in the root (where wp-config.php) is stored OR should it be in current theme's folder? Or should 2 copies be kept (which I don't want to do)? I know, either way will work and will result in no errors but I'd like to know better/correct/more semantical, etc. way.

share|improve this question

4 Answers 4

Even though there are quality answers here, I thought I'd throw in two cents from a different perspective. I manage many blogs and sites in a WordPress MultiSite environment, where the root directory is not an option. In these cases, it's best to put favicons in the theme directory as the WordPress Codex recommends.

share|improve this answer
    
As "the codex" recommends, you mean. The codex is a community editable wiki. You shouldn't take everything there as gospel. ;) I like to make a custom plugin to do my favicons on a per-site basis. But then I like plugins. –  Otto Jan 24 '12 at 6:00
    
Great point @Otto, I've edited my answer to be more clear. Thanks for the correction. –  Matthew Boynes Jan 24 '12 at 14:19

I would only store it in the theme folder if I expected the favicon to change when I change the theme. Which I don't.

A favicon is part of the total site identity, not a function of the CMS. What if you use non-WP software to run different parts of the site — e.g., a photo gallery, forum, or wiki (or all of the above)?

Put the favicon in the website root, and all software packages will have access to it, usually automatically (though you may have to remove hardcoded LINKs from individual themes).


(Edit) To clarify: If no LINK is specified, all modern web browsers (except Seamonkey, though an option exists to enable it) automatically look for a favicon at the root directory, i.e., example.com/favicon.ico. So there is no reason to add a LINK element, and good reason not to.

Furthermore, if the LINK element is malformed (has a typo, say) or the file located there is corrupt or in a format the browser doesn't understand, the browser will go looking for /favicon.ico anyway, so not having a file there will result in 404 errors in your logs.

There is one case where a LINK is appropriate, and that is if you want different favicons for different pages of your site.

share|improve this answer
    
More than 2/3s of professional web sites specify a favicon link. Do a view -> source on some of your favorites. Do you think they are all doing it wrong? –  user14432 Oct 10 '12 at 19:26
    
"Do you think they are all doing it wrong?" Read my answer above and you'll know exactly what I think. There are sometimes good reasons why the favicon can't go in the root directory (I listed one in my answer, but there are others). But unless you actually have a good reason to move the favicon and include a LINK element, then why would you? Because everyone else is doing it? Do the professional websites you surveyed have a REASON to do it that way? Do you? –  Doug Oct 10 '12 at 20:30

The Favicon isn't dynamic and doesn't "conflict" with anything else, with that in mind, I hard code it in the header.php and am then done with it.

share|improve this answer

It should always be in the root folder then it'll work whether you explicitly link to it or not.

You can also use this as a function in your theme's functions.php to explicitly link to it:

function my_favicon() {
    echo '<link rel="shortcut icon" href="' . get_bloginfo('wpurl') . '/favicon.ico" />';    
}
add_action('wp_head', 'my_favicon');
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.