I have two pages, page1,py and page2.py in my pages folder. page1.py calls page2.py, so I want to hide page2.py from the sidebar/side navigation. What is the simplest way to do this?
Happy to share more details on my attempts, but there ought to be a very simple way to hide a page. Or if I can move page2.py to a subfolder in page and then have page1.py call it via st.switch_page(“pages/subpages/page2.py”) that would work too, but seems like you can only switch_page to whatever is within the pages folder.
In a multipage app, you can hide the side bar by the following procedure.
.streamlit
folder under your app main folder..streamlit
folder create a config.toml
file and the content of this file is this.[client]
showSidebarNavigation = false
Now if you want to show a single page in the sidebar, for example the basketball page, you can create a page link widget and show it in the sidebar.
app.py
import streamlit as st
st.header('Home')
# Sidebar navigation
st.sidebar.page_link('app.py', label='Home')
st.sidebar.page_link('pages/basketball.py', label='Basketball')
basketball.py
import streamlit as st
st.header('Basketball')
# Sidebar navigation
st.sidebar.page_link('app.py', label='Home')
st.sidebar.page_link('pages/basketball.py', label='Basketball')
The soccer page is not shown.