Previous Section  < Day Day Up >  Next Section

Recipe 22.20. Using Favicons

22.20.1 Problem

All of your favorite web sites use favicons—for example, http://www.freebsd.org has a cute little devil that shows up in the URL bar of visitors' browsers and in their bookmarks. You want to make favicons for your web sites, too.

22.20.2 Solution

This requires creating a favicon.ico image in the precisely correct format—it must be a real .ico file, not a renamed bitmap or .jpg—and adding some entries to httpd.conf and to the headers of your web pages.

Your favicon must be 16 16 pixels in size, in 16 colors (4-bit), and be named favicon.ico. You need an image editor that is able to create .ico files, such as the Gimp, Babygimp, or Kiconedit. Kiconedit is especially nice and easy to use, though you'll also need the base KDE installation to use it.

Once you have created your beautiful favicon.ico, store it in your root datadir, which in the examples in this chapter is /var/www/. (See Recipe 22.2 to see a list of the configuration options used in this chapter.)

Next, add this entry to httpd.conf:

AddType image/x-icon .ico

Then add these lines to the headers of your web pages:

<link rel =icon href="/favicon.ico" type="image/x-icon">

<link rel="shortcut icon" href="/favicon.ico" type="image/x-icon">

The first line will display your favicon next to the URL of your web site in your visitors' web browsers, and the second line makes your favicon appear in visitors' bookmarks.

22.20.3 Discussion

If you aren't into creating your own favicons, a Google search for "favicon clip art" or "favicon gallery" will find you lots of ready-made icons to choose from.

If you are running virtual hosts, each one can have its own favicon. Just remember to add the AddType image/x-icon .ico line to each VirtualHost directive.

22.20.4 See Also

    Previous Section  < Day Day Up >  Next Section