How to switch to a streamlit page from html

Hi,
I have made a footer with html :

ft="""
<div style='font-size: 0streamlit .875em;color: #000;cursor: pointer;font-family: Inter;font-size: 14px;font-style: normal;font-weight: 500;line-height: 140%; /* 14px */'>
Footer
</div>
"""

st.write(ft, unsafe_allow_html=True)

is there a way please to use st.switch_page("pages/test.py") in html please ?

Not exactly. You can link to a specific page by using the page’s path, but it will start a new session, meaning you will reset Session State. You’d need to build a custom component that if you want to display custom HTML that communicates with the Python server to perform an action within a session.

thanks for your answer..do you have please any example of that ?
thanks

To link to a page from Markdown (and start a new session) use:

st.markdown("[Go to my page](/my_page)")

I don’t have a working example of a custom component to preserve the session, though.

it is not clear for me this solution..if you can provid more help please ? if you could provid an example it would be helpful

If you have:

your_working_directory/
├── pages/
│   ├── a_page.py
│   └── another_page.py
└── your_homepage.py

And you have some <ip:port> to access your app, then the address of the a_page.py file is:
<ip:port>/a_page

Therefore, you can add a link to that page in Markdown, like this:

import streamlit as st

st.markdown("Go to [Page A](/a_page)."

However, this type of link will not preserve Session State so it may not be an adequate solution. I don’t have an example using a custom component, which is necessary if you want to preserve the session.