Forums

Web2py Favicon

The favicon for my web2py app works on my local machine, where I place favicon.ico in the root of my appname folder.

So the directory is like: web2py/applications/appname/favicon.ico

and that works fine. However, this does not work for the same app in pythonanywhere. Is my web2py/applications/appname folder not considered the root folder for my site?

Simple question but I haven't been able to find any references for favicons in Pythonanywhere.

Hi marladarla,

Nope, that's not a public web root. You should put something like:

<link rel="shortcut icon"
    href="http://www.yoursite.co.nz/path-to/favicon.ico"
type="image/ico" />

In the header of your html. And the path to the favicon should be a static files directory.

thanks hansel!

I have a slightly different question. I am running a Django app and have written my favicon link as follows....

html <link rel="shortcut icon" href="{% static 'path_to_favicon' %}" type="image/png" />

The favicon is show as expected but and am getting Not Found: /favicon.ico in my error logs. It seems to me that the browser is looking for /favicon.io before Django servers it. Where can I store my favicons to prevent this issue?

You're only specifying the location for the png icon. See https://iconhandbook.co.uk/reference/examples/favicons/ for how to specify it for other types.