Adding a Meta description to your streamlit app

Think I got it figured out.

Demo: App Link | Facebook Sharing Debugger

The default index.html and favicon.png are stored in /site-packages/streamlit/static/

Replace <title>Streamlit</title> with:

<title>TITLE</title>
<meta name="title" content="TITLE">
<meta name="description" content="DESCRIPTION">
<meta property="og:type" content="website">
<meta property="og:url" content="URL">
<meta property="og:title" content="TITLE">
<meta property="og:description" content="DESCRIPTION">
<meta property="og:image" content="IMAGEURL>
<meta property="twitter:card" content="summary_large_image">
<meta property="twitter:url" content="URL">
<meta property="twitter:title" content="TITLE">
<meta property="twitter:description" content="DESCRIPTION">
<meta property="twitter:image" content="IMAGEURL">

I am using docker to deploy it to GCP cloud run. If you are doing something similar, make sure your Dockerfile has the following lines to replace index.html while building the container:

FROM python:3.10
EXPOSE 8080

COPY requirements.txt requirements.txt
RUN pip install -U pip
RUN pip install --no-cache-dir -r requirements.txt

# Most Important Line 
COPY index.html /usr/local/lib/python3.10/site-packages/streamlit/static/index.html
# Most Important Line 

COPY app.py app.py
COPY Images Images
COPY Text Text
COPY .streamlit .streamlit

WORKDIR .

ENTRYPOINT [ "streamlit", "run", "app.py", "--server.port=8080", "--server.address=0.0.0.0"]

Hope this helps!

5 Likes