Set_page_config layout defaulting to "centered" even after defining as "wide"

I have a mulitpage app where one page is set to st.set_page_config(layout=“wide”) and the other is just left to default. Sometimes when I refresh or rerun my dashboard after making changes, the page that is set to wide will show as centered. I try to refresh the page again but it doesn’t correct back to wide unless I make a new change to the code and run it again.

2 Likes

@sophia0 have you managed to find a solution for this issue?

This keeps happening to me as well. So far I have concluded that I have my st.set_page_config on a single page and unless after reloading I do not go to that page my layout settings are not recognized by the app.

This keeps happening to me as well. So far I have concluded that I have my st.set_page_config on a single page and unless after reloading I do not go to that page my layout settings are not recognized by the app.

This is correct. If you don’t set the page configuration on every page, then reloading a page or manually navigating to a page will lose the configuration if not set on that specific page. (Any page refresh or manual navigation starts a brand new session with no knowledge or memory of other pages.)

But you cannot set set_page_config on every page? It has to be set on one page only? When I try to put it on each page it gives me an error.

Can you share your code and error message? Or at least share how the first few lines of each page are that you are getting the error?

I got it! I had to call it before doing anything else, It has to be the first command. I was loading my CSS before it.