How to refer page in multipages?


The multipage tutorial is useful. However, it doesn’t mention how to refer pages.

Steps to reproduce

Let’s say we want to cite page2 using markdown in main_parge.

How to make [page2](??label??) jumping to page2?

Code snippet:

# Contents of ~/my_app/
import streamlit as st
st.title("Main page")

# Contents of ~/my_app/pages/
import streamlit as st
1 Like

thank you for this. It was a lot of help!! I wonder how can we jump to the page but stay in the same window or how to close the window we just left? I’m very new to Streamlit, sorry if it is a very beginner question. :handshake:

You can use this once you know the link of your website:

st.markdown('<a href="http://localhost:8501/page2" target="_self">page2</a>', unsafe_allow_html=True)

thank you!

The method described above by zxdawn will work, but it will reset the session state.
If you want to maintain the session state when you switch between pages of a multi-page app, then you’ll need the switch_page function:

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.