Hi team,
I created a web app and deploy it using Render.
I did also bought a domain and manage to link the domain with the streamlit app.
I even managed to add google analytics into it.
The problem that Iโm facing is that in google search the appโs title is Streamlit
and the description it says You need to enable JavaScript to run this app.
Like shown in the image below
You could potentially use st.markdown to inject custom HTML into your app, including meta tags, although this is more of a hack and its effectiveness might be limited since these tags need to be in the head section to be most effective.
Ok ! Managed to find a solution that actually worked.
In essence I had to modify the index.html file in /venv/lib/python3.10/site-packages/streamlit/static/index.html using a function that actually modifies the title and the noscript text.
def modify_tag_content(tag_name, new_content):
index_path = pathlib.Path(st.__file__).parent / "static" / "index.html"
logging.info(f'editing {index_path}')
soup = BeautifulSoup(index_path.read_text(), features="html.parser")
target_tag = soup.find(tag_name) # find the target tag
if target_tag: # if target tag exists
target_tag.string = new_content # modify the tag content
else: # if target tag doesn't exist, create a new one
target_tag = soup.new_tag(tag_name)
target_tag.string = new_content
try:
if tag_name in ['title', 'script', 'noscript'] and soup.head:
soup.head.append(target_tag)
elif soup.body:
soup.body.append(target_tag)
except AttributeError as e:
print(f"Error when trying to append {tag_name} tag: {e}")
return
# Save the changes
bck_index = index_path.with_suffix('.bck')
if not bck_index.exists():
shutil.copy(index_path, bck_index) # keep a backup
index_path.write_text(str(soup))
modify_tag_content('title', 'World Marathons Planner')
modify_tag_content('noscript', 'Best Marathon Planner ! Browse through the event selection and discover your next Marathon challenge. Also get specific and personalized training plans.')
Final result.
Probably there is a better solution out there, but at least this one worked on my side
Thanks once again to those who answer before, appreciate it
Have you found a way to make this work for the favicon as well? I know the only other way to do this is to change the streamlit index.html file located within the site-packages but this is difficult to do especially for those who do not have complete control over their requirement.txt files i.e deployment through Heroku in my case.
Thanks for stopping by! We use cookies to help us understand how you interact with our website.
By clicking โAccept allโ, you consent to our use of cookies. For more information, please see our privacy policy.
Cookie settings
Strictly necessary cookies
These cookies are necessary for the website to function and cannot be switched off. They are usually only set in response to actions made by you which amount to a request for services, such as setting your privacy preferences, logging in or filling in forms.
Performance cookies
These cookies allow us to count visits and traffic sources so we can measure and improve the performance of our site. They help us understand how visitors move around the site and which pages are most frequently visited.
Functional cookies
These cookies are used to record your choices and settings, maintain your preferences over time and recognize you when you return to our website. These cookies help us to personalize our content for you and remember your preferences.
Targeting cookies
These cookies may be deployed to our site by our advertising partners to build a profile of your interest and provide you with content that is relevant to you, including showing you relevant ads on other websites.