Migrating my app to pages - referencing assets folder from pages

Hi Everyone,

I am embarking on what seems a very roundabout way to migrate my current app from a flask paginated app to the dash pages.

I am busy changing my file structure which includes the recommended format being app.py then a pages folder which reads the pages etc.

I am able to read my pages no problem and load them, the problem I am, having is including my assets folder in my pages themselves, I have my custom CSS and some images which are page specific in the assets folder which sits on the same level as the pages folder.

How do I go about including my asset folder in my page-specific report?

Many Thanks,

Hi @DrSmith69

Dash multi-page apps do not support a separate assets file for each page. However, you can find more information about how to have page related css in this thread: Add a css file to a page in Multipage app. Also, more info on how to include images: How to Embed Images into a Dash App

You could put the css in different files, but it would still apply to the whole app. The file structure might look something like:

- app.py 
- assets
    |-- page1.css
    |-- page2.css
    |-- page1.png
    |-- page2.png
- pages          
    |-- page1.py
    |-- page2.py
 
2 Likes

dash.get_asset_url was the solution :slight_smile: was trying to do app.get_asset_url and that just wasn’t happy at all as I had updated dash to get dash pages, images are showing up now thank you very much!

1 Like