Using markdown to call a page in multipage app?

Hi, I love the new Streamlit Multipage support in v1.10+. But I don’t love the page list on the sidebar because I don’t want all the subpages to be listed. So I’m trying to implement a top menu to bring up only pages I like to call instead of showing all the pages.

However no matter how I setup my href link, it always bring up the page in a new tab. For example, using a markdown like below:

st.markdown("<a href='subpage'>subpage</a>", unsafe_allow_html=True)

This will bring up a new browser tab for me even though I follow exactly the same referenced href spec in the sidebar page listing. Any idea how I may be able to circumvent this? Or may be our Streamlit masters can figure out a hack to imitate the same call as the sidebar page links?

Thanks!
Andy W

Try add target property in a tag.

st.markdown("<a href='subpage' target='_self'>subpage</a>", unsafe_allow_html=True)
1 Like

This works! Thanks much @ji_haoran. Not sure why target=“_blank” didn’t work for me.

Calling a page using markdown requires a full refresh (e.g. the sidebar redraws) whereas clicking on the page name in the sidebar is much faster. I’m assuming state variables will not work as well.

Is there a way to get the same fast page load behavior like from the sidebar using the markdown method? The hrefs are exactly the same. Odd.

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