New package st-pages: change page names and icons in sidebar without changing filenames

Can you check to see if you have the latest version of st_pages installed? You can see that code working fine here https://st-pages-sections.streamlit.app/

Very cool!!!

Hey @blackary, I have built a streamlit app (in version 1.11.1) where all pages are defined in the pages folder in a particular order. I wish to hide all pages before user logs into the app and was tryingt he follow the approach you’ve mentioned above.

I’m tried to import different modules from st_pages as suggested above, but I’m getting an error that says: cannot import name ‘runtime’ from ‘streamlit’. What shall I try next?

The best solution will probably be to upgrade to a more recent version of streamlit

Yeah it works after upgrading the library, thanks!

1 Like

i managed to get it working finally! i decided to use the pages.toml file.

a few remarks though:

  • You cant leave the icon field behind, if you dont want to use it, you have to specify that its empty:
    wrong:
    [[pages]]
    path = “script.py”
    name = “Page Name”

correct:
[[pages]]
path = “script.py”
name = “Page Name”
icon = “”

  • Some of the emojis inside the icon string wont be recognized and giving an error, i decided to place all emojis and icos inside the page name.
    correct:
    [[pages]]
    path = “script.py”
    name = “:christmas_tree: Page Name”
    icon = “”

Hi @Christian, thanks for the feedback.

You shouldn’t need to add an empty icon – you can see an example here that doesn’t specify an icon, and it works fine https://github.com/blackary/st_pages/blob/main/example_app/.streamlit/pages.toml#L21

What do you mean by icons “won’t be recognized”? Can you give an example of one that isn’t recognized?