Search code examples
rshinymeta-tags

How can I include meta tags in my R Shiny app?


I tried adding the following, but the published app doesn't seem to include my meta tags. The source code shows that the stuff inside of the head tags appears to be default content. I'd like to make my app searchable.

tags$head(
  tags$meta(charset="UTF-8"),
  tags$meta(name="description", content="..."),
  tags$meta(name="keywords", content="..."),
  tags$meta(name="viewport", content="width=device-width, initial-scale=1.0")
)

ui<-fluidPage(...)

Solution

  • Just make sure you include the meta tags in the fluidPage object. Shiny will pull out all the tags in the head to the appropriate place.

    ui<-fluidPage(
      tags$head(
        tags$meta(charset="UTF-8"),
        tags$meta(name="description", content="..."),
        tags$meta(name="keywords", content="..."),
        tags$meta(name="viewport", content="width=device-width, initial-scale=1.0")
      ), ...)