Forums

Favicon in Django

Can someone walk me through on how to setup Favicon on my site? Thank you in advance.

I believe the way we're meant to do favicons these days is through an extra bit of code in the HTML. Each page should have something like this (which you can do in your base template):

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

Once you've done that, you can set up a static file mapping (if you don't have one already) so that the URL http://www.yoursite.com/static/favicon.ico goes to a file that contains the desired icon.

Giles What do you mean by base template mapping? where is it locate it at? Sorry I am new to this. I already have a static folder that hold all my pictures. Thank you for your help.

The normal setup when you use Django is to have a "base template", which includes the basic structure that is common to all of your pages -- see this part of the Django Girls tutorial for a nice introduction to how they work.

If you do that, then if you want a particular line of HTML, like the one in my last post, to appear on every page in your site, then you just specify it once, in the base template.

Once you've done that, you just need to make the favicon available as a static file in the same way as the ones you already have, and make sure that the link in the line of HTML points at it correctly.