If you want to create .ico files, you can also use GIMP to create favicons. Modern browsers can use normal image files, but originally I think it was just .ico files. It's an open source image editor similar to Photoshop. Create and edit an image of the right size (say 32 x 32), flatten to one layer (Unless you want multiple icons in the same file), and save as a .ico. It'll format it correctly, then use Stefano's <link rel="SHORTCUT ICON" HREF="/favicon.ico"> to use it in your webpage.
If you already have a logo image that you want to transform into a favicon, then you can convert it using http://www.favicomatic.com/.
It creates crisp favicons, and I haven't had to edit them after creating them.
It will generate favicons at 16x16 and 32x32 and to quote them: "Every damn size, sir!". The site also supports/preserves transparency present in some pngs.
Also, their site looks cool and is easy to use.
When creating a favicon, you want to take the following factors into account:
Supported platforms Ten years ago, you only wanted to support desktop browsers and the solution was to generate the classic favicon.ico picture. Nowadays, you want to support iOS (and iOS Safari) and Android (and Android Chrome). Maybe Windows 10 (and Edge) and the new Mac Book Pro Touch Bar, too (macOS Safari). You cannot just use a single "one size fits all" image anymore.
Design As soon as you support multiple platforms, you are facing multiple design guidelines. For example, Google is using transparent icons for its own native apps on Android, while iOS icons cannot be transparent at all. You cannot just use a "single design fits all" approach.
Generated icons and HTML code For two or three years, the reference has been to generate as many icons as possible in order to cover all cases. I am afraid I created this trend all by myself :-/ The problem is that you end up with 20-something lines or HTML, which is way too much. In order to have a satisfying technical solution, you need to balance the amount of generated icons/HTML and the supported platforms.
As usual, you can create all these assets manually. Unless you have very, very specific needs and a budget, this is definitely not the way to go.
The right way for most people is to use a favicon generator that lets you decide of the look of all the icons and takes care of all the details. The only one which does this is Real Favicon Generator. Full disclosure: I am the author of this site.