Quick answer
Flask exposes the application static directory under /static by default. For conventional root assets such as /favicon.ico, add a small explicit route or configure the production web server to serve the file directly.
- Last verified
- July 31, 2026
- Evidence
- Primary documentation plus a route-specific implementation example
- Primary sources
- 2
Project paths and constraints
Flask exposes the application static directory under /static by default. For conventional root assets such as /favicon.ico, add a small explicit route or configure the production web server to serve the file directly.
Flask’s default static URL is /static, not the hostname root. Reverse-proxy prefixes and an application factory can change generated URLs, so use the deployed request context as evidence.
Connected next stepDjango Favicon Guide: Static Files, Routes & HTML for the closest prerequisite or comparison.
Declare favicon metadata once
Put the icon links in the shared Jinja base template and generate URLs with url_for when assets live under the static endpoint. Keep manifest paths consistent with their final public location.
Generate static icon URLs with url_for in the inherited base template. Reserve an explicit endpoint or proxy rule for conventional root files rather than duplicating link elements across blueprints.
Connected next stepLaravel Favicon Guide: Public Files, Blade & Caching for the next connected implementation decision.
Build, deploy, and verify
Test through the production WSGI server and reverse proxy, not only Flask’s development server. Confirm MIME types, cache headers, proxy prefixes, and every generated public URL.
A development-server 200 can become a proxy 404 or wrong MIME type in production. Verify through the public WSGI and proxy chain, including any explicit root favicon route.
Connected next stepOpen the most relevant production tool and verify the decision with a working output.
Test Flask behind the real proxy prefix
Within the production request context, render one shallow and one nested route and record the generated static URLs. Check APPLICATION_ROOT, static_url_path, ProxyFix or equivalent proxy configuration, and the external HTTPS scheme used by url_for.
Request the files through the WSGI server and front proxy, including /favicon.ico if you support the conventional probe. A useful result includes the final URL, image Content-Type, cache header, and decoded file—not merely a 200 from the development server.
Flask root routes and proxy prefixes
Flask normally serves assets below its configured static_url_path. If /favicon.ico must exist at the hostname root, create a narrow explicit response or proxy rule instead of a catch-all that can return the HTML application shell.
Generate template URLs inside the deployed request context and account for any reverse-proxy prefix. Verify status, Content-Type and bytes through the public WSGI/proxy chain rather than relying on the development server.
Production file tree and code: Flask static endpoint and Jinja links
url_for follows the configured static endpoint and application context. Add a distinct root-file route only for conventional /favicon.ico discovery.
app/
├── static/icons/favicon.svg
├── static/icons/favicon.ico
└── templates/base.html
routes.py<link rel="icon" href="{{ url_for('static', filename='icons/favicon.svg') }}" type="image/svg+xml">
<link rel="icon" href="{{ url_for('static', filename='icons/favicon.ico') }}">Review the headings, sources, implementation artifact, and update record for this guide as structured JSON.
Download guide evidence ↓- Guide
- Flask Favicons: Static Files, Root Routes and Proxies
- Coverage
- Client behavior can change by browser, operating system, platform version, cache state and deployment configuration. Unperformed manual observations are not claimed.
Questions, answered
Does Flask serve /favicon.ico automatically?+
No. The default static endpoint is normally under /static. Add a narrow root route or let the production web server serve the conventional file.
Why does url_for create the wrong icon URL behind a proxy?+
The application may not know the external scheme or path prefix. Configure trusted proxy handling and test URL generation in the deployed request context.
