Images not displaying in a published Shiny app
This article helps diagnose why images appear locally but do not display after publishing a Shiny app, and outlines the most common fixes related to asset paths, deployment structure, and HTTPS.
Introduction
Images might fail to display in a deployed Shiny application on shinyapps.io, even when image references appear to work correctly during local development.
Problem
Images do not display in a published Shiny application on shinyapps.io, despite appearing correctly when the app is run locally.
This issue typically occurs when image files are not included in the deployment bundle. On shinyapps.io, only files inside the application directory are uploaded during publishing. If you store image assets outside the app directory or do not place them in the www/ folder, they are not available at runtime.
Solution
To ensure images are included and displayed correctly in a deployed Shiny application:
- Create a folder named
wwwin your Shiny app’s root directory if it does not already exist. - Place all image files referenced by your app inside the
wwwfolder. - Reference images in your UI code using only the filename (for example,
"logo.png"). Do not includewww/in the path, as Shiny automatically serves files from this directory.
Example
ui <- fluidPage(
img(src = "logo.png", height = "80px")
)