6

I have been trying to find a way to associate a .ico with a shortcut to a shiny app hosted on an open source shiny server. Ultimately I would like the .ico to appear as the graphic for the shortcut to my app. And, I would like this icon to appear/be available for users when they create a shortcut to the app. (sounds simple enough but has proven to be a pretty difficult task). After a bunch of dead ends, I thought I would just work on getting the icon to display on the tab in the browser, and be available when someone favorites it.

I have found the following: Favicon in Shiny, https://groups.google.com/forum/#!topic/shiny-discuss/nU0AP8k0fvU, but the procedures don't seem to work with shiny server.

I can get the favicon to display on my local machine by saving it in the www folder of the app, but when I run the app from Rstudio server or from the shiny server via a link/shortcut, the .ico will not appear.

I found a related discussion where it was determined this was not possible https://github.com/rstudio/shinydashboard/issues/102

However...I still think it is because I was browsing the shiny gallery and noticed apps in the gallery display with a shiny icon in the browser tab. The only icon I can get to appear using shiny server is the empty document icon. Also, when I run my app with Rstudio server, the Rstudio R icon displays in the browser tab of the app, so its fishy.

Can anyone give some insight as to what is going on, and how I can get a nifty custom graphic for my shiny app?

roberty boberty
  • 175
  • 2
  • 8
  • Can you add to your question a basic example of how are you adding the favicon to your app? – Geovany Mar 15 '19 at 17:12
  • I have just put it in the www folder. I uploaded the .ico into a www folder associated with the app using rstudio server. Then I opened the terminal to copy the app into srv/shiny_server. When I run the app from my local R session on my comp, the icon loads fine. when I run the app from Rstudio server, Rstudio icon loads, and when I run the app from a shortcut (so that shiny server is actually running the app), i get the empty doc icon. – roberty boberty Mar 15 '19 at 19:54
  • How are you making reference to the favicon file in your ui.R file? – Geovany Mar 15 '19 at 20:09
  • I'm not... I just put it into a www folder with the app, where it should be auto detected (which it is auto detected locally btw) – roberty boberty Mar 18 '19 at 14:08

1 Answers1

5

Try adding inside your dashboardBody function or in the UI function you are using:

tags$head(tags$link(rel = "shortcut icon", href = "favicon.ico"))

If you have a .PNG file or both, you can use:

tags$head(
  tags$link(rel = "shortcut icon", href = "favicon.ico"),
  tags$link(rel = "apple-touch-icon", sizes = "180x180", href = "favicon.ico"),
  tags$link(rel = "icon", type = "image/png", sizes = "32x32", href = "/favicon-32x32.png"),
  tags$link(rel = "icon", type = "image/png", sizes = "16x16", href = "/favicon-16x16.png")
)
Geovany
  • 5,389
  • 21
  • 37