How to add a favicon in Django
In Django, favicons are static files. Link them from your base template with the static tag, and add one URL so /favicon.ico doesn’t 404.
Steps
- Copy the package files into a static folder, e.g. myapp/static/favicons/.
- In your base template, load static and add the link tags (below).
- Add a redirect for /favicon.ico in urls.py so browsers and bots that request it directly get the icon.
- Run collectstatic in production so the files reach your static host.
File to use: the whole package, into an app’s static/ folder. Make it with the favicon generator (free, no signup).
Code
base.html and urls.py
{% load static %}
<link rel="icon" href="{% static 'favicons/favicon.ico' %}" sizes="48x48">
<link rel="icon" href="{% static 'favicons/favicon.svg' %}" type="image/svg+xml">
<link rel="apple-touch-icon" href="{% static 'favicons/apple-touch-icon.png' %}">
# urls.py
from django.templatetags.static import static
from django.views.generic.base import RedirectView
urlpatterns += [
path('favicon.ico', RedirectView.as_view(url=static('favicons/favicon.ico'), permanent=True)),
]Good to know
- Edit the icon paths inside site.webmanifest to match your static URL (for example /static/favicons/android-chrome-192x192.png).
- Behind nginx, you can serve /favicon.ico directly with a location block instead of the Django redirect.
Check it worked
Run the favicon checker on your live URL to confirm every icon loads and Google has a usable size. If the old icon keeps showing, see favicon not showing. The full tag-by-tag explanation is in how to add a favicon.
Other platforms: WordPress · Next.js · Shopify · Squarespace · Wix · React · Webflow · Astro
Questions people ask
Why does Django log 404s for /favicon.ico?
Browsers request /favicon.ico at the site root regardless of your link tags. Add a redirect URL to the static file, or serve it from your web server.
Where should I put the favicon in Django?
In an app’s static directory, referenced with the {% static %} template tag in your base template.