Streamlit Favicon: Add a Custom Tab Icon Step by Step
You've built a clean Streamlit dashboard, shared the link with your team, and then someone asks: “Why does the browser tab show a generic Streamlit logo instead of our brand?” The fix is one parameter you probably skipped: page_icon. This tutorial shows you exactly how to set a Streamlit favicon using a local image, an emoji, or a URL, and how to verify it actually appears in the tab.
What page_icon actually controls
Streamlit renders your app inside a page it generates. The st.set_page_config() function accepts a page_icon argument that tells Streamlit which icon to use for the browser tab and, in some browsers, for bookmarks. It is not a full HTML favicon stack — it is Streamlit's own hook for the tab icon.
According to the HTML specification, a favicon is declared with a rel="icon" link in the document head (WHATWG HTML spec). Streamlit handles that link for you when you pass page_icon. If you want the full context on what a favicon is and where it appears, see our guide to what a favicon is.
Prerequisites
A working Streamlit app (any version that supports st.set_page_config).
An icon file: a square PNG, JPG, or SVG. For best results, use a square image at least 64×64 px.
Basic familiarity with running streamlit run app.py.
Step-by-step: set your Streamlit favicon
Step 1 — Call set_page_config first
st.set_page_config() must be the first Streamlit command in your script. If you call st.title() or any other Streamlit function before it, Streamlit raises an error. Put it at the very top of your app file, right after imports.
import streamlit as st
st.set_page_config(
page_title="My Dashboard",
page_icon="icon.png"
)
st.title("My Dashboard")
Step 2 — Point page_icon at your image
The page_icon value can be:
A relative path to an image file in your project, like "icon.png".
An absolute path, like "/home/user/app/icon.png".
A URL to an image, like "https://example.com/icon.png".
A single emoji character, like "🚀".
For a brand icon, a local PNG or SVG is the most reliable choice. Keep the file in the same directory as your app script, or use a path relative to where you run streamlit run.
Step 3 — Use an emoji if you don't have an image yet
If you're prototyping, an emoji is the fastest option. Streamlit converts it to an icon for the tab:
This is handy for internal tools, but it won't match your brand. When you're ready to ship, swap it for a real image file.
Step 4 — Prepare a proper icon file
Streamlit accepts common image formats, but a square PNG with a transparent background works best across browsers. If you only have a logo, crop it to the mark and resize it to 64×64 or 128×128 px. Our guide to making a favicon from an image walks through the cropping and simplification steps.
If you need an ICO file for other surfaces, you can convert your PNG with Mzu favicondl. Streamlit itself does not require ICO, but having one helps if you also serve the app behind a custom domain that uses a traditional favicon.
Step 5 — Verify the tab icon
Run your app, open it in a browser, and look at the tab. If you still see the default Streamlit icon, do a hard refresh (Ctrl+Shift+R or Cmd+Shift+R). Browsers cache favicons aggressively, so the old icon can stick around even after your code change. For a deeper checklist, see favicon not showing.
Common pitfalls
Calling set_page_config too late. It must be the first Streamlit call. Moving it to the top fixes the error.
Wrong file path. A relative path is resolved from the directory where you launch Streamlit, not from the script's folder. Use an absolute path if you're unsure.
Non-square images. A wide logo gets squashed or letterboxed. Crop to a square first.
Browser cache. The tab may show the old icon for a while. Hard refresh or test in a private window.
Deployment path differences. On Streamlit Community Cloud or a container, the working directory may differ from your local setup. Use a path relative to the app file or an absolute path that exists in the deployed environment.
When you need more than page_icon
page_icon covers the browser tab for the Streamlit app itself. If you embed the app in a larger site, or if you need Apple Touch icons and a web app manifest, those are separate concerns handled by the surrounding HTML. For a complete icon stack, see our favicon best practices.
Setting a Streamlit favicon is a one-line change once you know where to put it. Start with st.set_page_config(page_title=..., page_icon=...) at the top of your script, use a square PNG or SVG, and verify with a hard refresh. That's enough to replace the default Streamlit logo with your own brand in the tab.
按照 HTML 规范,favicon 需要通过文档 head 中的 rel="icon" link 声明(WHATWG HTML spec)。传入 page_icon 后,Streamlit 会替你处理这个 link。如果想进一步了解 favicon 是什么,以及它会出现在哪些位置,可以阅读我们的favicon 指南。
HTML 仕様では、favicon は document の head にある rel="icon" link で宣言されます(WHATWG HTML spec)。page_icon を渡すと、その link の設定を Streamlit が自動的に処理します。favicon とは何か、どこに表示されるのかについて詳しく知りたい場合は、what a favicon is のガイドをご覧ください。
깔끔한 Streamlit 대시보드를 완성하고 팀에 링크를 공유했는데, 누군가 이렇게 물었습니다. “브라우저 탭에 우리 브랜드 대신 일반적인 Streamlit 로고가 표시되는 이유는 무엇인가요?” 해결책은 아마 건너뛴 매개변수 하나인 page_icon에 있습니다. 이 튜토리얼에서는 로컬 이미지, emoji, URL을 사용해 Streamlit favicon을 설정하고, 실제로 탭에 표시되는지 확인하는 방법을 단계별로 설명합니다.
page_icon이 실제로 제어하는 범위
Streamlit은 앱을 자동으로 생성한 페이지 안에서 렌더링합니다. st.set_page_config() 함수는 브라우저 탭에 어떤 아이콘을 사용할지, 그리고 일부 브라우저에서는 즐겨찾기에 어떤 아이콘을 사용할지를 지정하는 page_icon 인수를 받습니다. 이것이 완전한 HTML favicon 구성인 것은 아닙니다. 탭 아이콘을 설정하기 위한 Streamlit 자체의 훅입니다.
HTML 명세에 따르면 favicon은 문서의 head에 rel="icon" 링크를 추가해 선언합니다(WHATWG HTML spec). page_icon을 전달하면 Streamlit이 이 링크를 대신 처리합니다. favicon이란 무엇이며 어디에 표시되는지 자세히 알고 싶다면 favicon이란 무엇인가에 대한 가이드를 참고하세요.
사전 준비 사항
정상적으로 실행되는 Streamlit 앱이 필요합니다. st.set_page_config를 지원하는 버전이어야 합니다.
아이콘 파일이 필요합니다. 정사각형 PNG, JPG 또는 SVG를 사용하세요. 가장 좋은 결과를 위해 최소 64×64 px 크기의 정사각형 이미지를 사용하세요.
streamlit run app.py를 실행하는 기본적인 사용법만 알고 있으면 됩니다.
단계별 안내: Streamlit favicon 설정하기
1단계 — set_page_config를 가장 먼저 호출
st.set_page_config()는 스크립트에서 가장 먼저 실행되는 Streamlit 명령어여야 합니다. 그 전에 st.title()이나 다른 Streamlit 함수를 호출하면 Streamlit이 오류를 발생시킵니다. 앱 파일의 맨 위에 import 바로 다음에 배치하세요.
import streamlit as st
st.set_page_config(
page_title="My Dashboard",
page_icon="icon.png"
)
st.title("My Dashboard")
2단계 — page_icon에서 이미지 지정
page_icon에는 다음 값을 사용할 수 있습니다.
프로젝트 내 이미지 파일의 상대 경로입니다. 예를 들어 "icon.png"처럼 지정합니다.
절대 경로입니다. 예를 들어 "/home/user/app/icon.png"처럼 지정합니다.
이미지 URL입니다. 예를 들어 "https://example.com/icon.png"처럼 지정합니다.
이모지 한 글자입니다. 예를 들어 "🚀"처럼 지정합니다.
브랜드 아이콘에는 로컬 PNG 또는 SVG를 사용하는 것이 가장 안정적입니다. 파일을 앱 스크립트와 같은 디렉터리에 두거나, streamlit run을 실행하는 위치를 기준으로 한 상대 경로를 사용하세요.
3단계 — 이미지가 아직 없다면 이모지 사용
프로토타이핑 중이라면 이모지를 사용하는 것이 가장 빠릅니다. Streamlit가 이를 탭 아이콘으로 변환합니다.
내부 도구에는 편리하지만 브랜드와는 일치하지 않습니다. 릴리스할 준비가 되면 실제 이미지 파일로 교체하세요.
4단계 — 적합한 아이콘 파일 준비
Streamlit는 일반적인 이미지 형식을 지원하지만, 여러 브라우저에서 가장 잘 맞는 것은 투명 배경의 정사각형 PNG입니다. 로고만 있다면 마크 부분만 잘라내고 64×64 또는 128×128 px 크기로 조정하세요. 이미지에서 favicon을 만드는 방법에 관한 가이드에서 자르기와 단순화 단계를 자세히 설명합니다.
다른 곳에서도 ICO 파일이 필요하다면 Mzu favicondl을 사용해 PNG를 변환할 수 있습니다. Streamlit 자체는 ICO를 요구하지 않지만, traditional favicon을 사용하는 custom domain에서 앱을 제공하는 경우에도 ICO 파일을 하나 준비해 두면 도움이 됩니다.
5단계 — 탭 아이콘 확인
앱을 실행한 뒤 브라우저에서 열고 탭을 확인하세요. 기본 Streamlit 아이콘이 계속 보인다면 강력 새로고침(Ctrl+Shift+R 또는 Cmd+Shift+R)을 실행하세요. 브라우저는 favicon을 강하게 캐시하므로 코드를 변경해도 기존 아이콘이 오래 남을 수 있습니다. 더 자세한 확인 항목은 favicon이 표시되지 않을 때를 참고하세요.
자주 발생하는 문제
set_page_config 호출 시점이 너무 늦었습니다. 반드시 Streamlit에서 처음 호출하는 API여야 합니다. 코드를 맨 위로 옮기면 오류가 해결됩니다.
파일 경로가 잘못되었습니다. 상대 경로는 스크립트가 있는 폴더가 아니라 Streamlit을 실행한 디렉터리를 기준으로 해석됩니다. 경로가 확실하지 않다면 절대 경로를 사용하세요.
이미지가 정사각형이 아닙니다. 가로로 긴 로고는 정사각형 영역에 맞게 눌리거나 레터박스로 표시됩니다. 먼저 정사각형으로 crop하세요.
브라우저 캐시입니다. 탭에 이전 아이콘이 잠시 남아 있을 수 있습니다. 하드 새로고침을 하거나 private window에서 테스트하세요.
배포 환경마다 경로가 다릅니다. Streamlit Community Cloud나 container에서 실행하면 working directory가 로컬 환경과 다를 수 있습니다. 앱 파일을 기준으로 한 상대 경로 또는 배포 환경에 실제로 존재하는 절대 경로를 사용하세요.
page_icon만으로 부족한 경우
page_icon은 Streamlit 앱 자체의 브라우저 탭 아이콘을 설정합니다. 앱을 더 큰 사이트에 임베드하거나 Apple Touch icon과 web app manifest가 필요하다면, 이 항목들은 주변 HTML에서 별도로 처리해야 합니다. 완전한 icon stack을 구성하려면 favicon best practices를 참고하세요.
Streamlit favicon 설정은 아이콘을存放할 위치를 알고 나면 한 줄의 코드 변경으로 끝납니다. 스크립트 맨 위에서 st.set_page_config(page_title=..., page_icon=...)을 추가하고, 정사각형 PNG 또는 SVG를 사용한 다음 하드 새로고침으로 확인하세요. 이렇게만 설정하면 브라우저 탭의 기본 Streamlit 로고를 자체 브랜드 아이콘으로 바꿀 수 있습니다.
Has creado un dashboard de Streamlit limpio, has compartido el enlace con tu equipo y alguien te pregunta: «¿Por qué la pestaña del navegador muestra el logotipo genérico de Streamlit en lugar del de tu marca?» La solución es un parámetro que seguramente te has saltado: page_icon. En este tutorial te explicamos paso a paso cómo definir un favicon de Streamlit con una imagen local, un emoji o una URL, y cómo comprobar que aparece realmente en la pestaña.
Qué controla realmente page_icon
Streamlit renderiza tu app dentro de una página que genera. La función st.set_page_config() acepta el argumento page_icon, que le indica a Streamlit qué icono debe utilizar en la pestaña del navegador y, en algunos navegadores, en los marcadores. No se trata de un stack completo de HTML favicon, sino del mecanismo propio de Streamlit para controlar el icono de la pestaña.
Según la especificación HTML, un favicon se declara mediante un enlace rel="icon" en el head del documento (especificación HTML de WHATWG). Cuando le pasas page_icon, Streamlit se encarga de ese enlace por ti. Si quieres saber más sobre qué es un favicon y dónde aparece, consulta nuestra guía sobre qué es un favicon.
Requisitos previos
Una app de Streamlit que funcione (cualquier versión compatible con st.set_page_config).
Un archivo de icono: un PNG, JPG o SVG cuadrado. Para obtener el mejor resultado, utiliza una imagen cuadrada de al menos 64×64 px.
Lo básico sobre cómo ejecutar streamlit run app.py.
Cómo definir tu favicon de Streamlit paso a paso
Paso 1 — Llama primero a set_page_config
st.set_page_config() debe ser el primer comando de Streamlit de tu script. Si llamas antes a st.title() o a cualquier otra función de Streamlit, Streamlit genera un error. Coloca la llamada al principio del archivo de tu app, justo después de los imports.
import streamlit as st
st.set_page_config(
page_title="My Dashboard",
page_icon="icon.png"
)
st.title("My Dashboard")
Paso 2 — Apunta page_icon a tu imagen
El valor de page_icon puede ser:
Una ruta relativa a un archivo de imagen de tu proyecto, como "icon.png".
Una ruta absoluta, como "/home/user/app/icon.png".
Una URL a una imagen, como "https://example.com/icon.png".
Un único carácter emoji, como "🚀".
Para el icono de tu marca, un PNG o SVG local es la opción más fiable. Mantén el archivo en el mismo directorio que el script de tu app o utiliza una ruta relativa al directorio desde el que ejecutas streamlit run.
Paso 3 — Usa un emoji si todavía no tienes una imagen
Si estás haciendo un prototipo, un emoji es la opción más rápida. Streamlit lo convierte en un icono para la pestaña:
Te resulta útil para herramientas internas, pero no coincidirá con tu marca. Cuando estés listo para publicar, cámbialo por un archivo de imagen real.
Paso 4 — Prepara un archivo de icono adecuado
Streamlit acepta los formatos de imagen habituales, pero un PNG cuadrado con fondo transparente funciona mejor en distintos navegadores. Si solo tienes un logo, recórtalo para que aparezca únicamente el símbolo y redimensiona el resultado a 64×64 o 128×128 px. Nuestra guía para crear un favicon a partir de una imagen explica los pasos de recorte y simplificación.
Si necesitas un archivo ICO para otros usos, puedes convertir tu PNG con Mzu favicondl. Streamlit no requiere ICO por sí mismo, pero tenerlo ayuda si también sirves la app detrás de un dominio personalizado que utiliza un favicon tradicional.
Paso 5 — Verifica el icono de la pestaña
Ejecuta tu app, ábrela en un navegador y mira la pestaña. Si todavía ves el icono predeterminado de Streamlit, haz una recarga forzada (Ctrl+Shift+R o Cmd+Shift+R). Los navegadores guardan los favicon en caché de forma agresiva, por lo que el icono antiguo puede seguir apareciendo incluso después de cambiar el código. Para una lista de comprobación más detallada, consulta nuestra guía sobre el favicon que no aparece.
Problemas comunes
Invocar set_page_config demasiado tarde. Debe ser la primera llamada de Streamlit. Si la mueves al principio, se corrige el error.
Ruta de archivo incorrecta. Una ruta relativa se resuelve desde el directorio desde el que inicias Streamlit, no desde la carpeta del script. Usa una ruta absoluta si no estás seguro.
Imágenes no cuadradas. Un logo ancho se deforma o aparece con barras laterales. Recórtalo a un formato cuadrado antes.
Caché del navegador. La pestaña puede mostrar el icono anterior durante un tiempo. Haz una recarga forzada o prueba en una ventana privada.
Diferencias en las rutas de despliegue. En Streamlit Community Cloud o en un contenedor, el directorio de trabajo puede ser distinto al de tu entorno local. Usa una ruta relativa al archivo de la app o una ruta absoluta que exista en el entorno de despliegue.
Cuando necesitas más que page_icon
page_icon cubre la pestaña del navegador para la propia app de Streamlit. Si integras la app en un sitio más grande o necesitas Apple Touch icons y un web app manifest, son asuntos separados que gestiona el HTML que rodea la app. Para un conjunto completo de iconos, consulta nuestras prácticas recomendadas para favicons.
Configurar un favicon de Streamlit es un cambio de una línea una vez que sabes dónde colocarlo. Empieza con st.set_page_config(page_title=..., page_icon=...) en la parte superior del script, usa un PNG o SVG cuadrado y comprueba el resultado con una recarga forzada. Eso es suficiente para sustituir el logo predeterminado de Streamlit por tu marca en la pestaña.
Need a clean icon file for Streamlit?
Use Mzu favicondl to crop, resize, and convert your logo into a square PNG or ICO ready for page_icon.