CRAN status metathis status badge Lifecycle: stable R-CMD-check Codecov

Why metathis?

The goal of metathis is to help you add HTML <meta> tags to your R Markdown and Shiny apps.

HTML <meta> tags provide browsers and social media with metadata about HTML pages. Using <meta> tags will help your users find your articles, Shiny apps, and presentations, and will help you make sure they look great in social media timelines.

metathis makes the process of adding these tags to your R Markdown pages and Shiny apps easier by using the htmltools package to add <meta> tags as a dependency, added directly to the document in an R code chunk or your Shiny app UI rather than requiring you to adjust templates or write additional files.

If you want great looking social media cards, the meta_social() function will help you add everything you need for Twitter, Facebook and other social media sites that support the Open Graph protocol.


You can install the latest version of metathis from CRAN with:


And the development version from Github or r-universe with:

# r-universe
install.packages("metathis", repos = "")

# install.packages("devtools")

Works In

R Markdown HTML Documents
Shiny Apps

<meta> tags can be added to ✅ packages with a standard R chunk

```{r, echo=FALSE}
meta() %>% 
  meta_description("My awesome presentation")

For other packages or situations, you can use include_meta() to explicitly declare the meta tags as an html dependency or use write_meta() to save the <meta> tags to an .html file that can be included via includes: in_header. (In blogdown, consult your blogdown/hugo theme for the correct inclusion method.)

```{r blogdown-meta, echo = FALSE}
meta() %>% 
  meta_description("A fantastic blog post") %>% 


In R Markdown

This is a basic example that re-creates the <meta> tags for the R for Data Science book.

meta() %>%
    "This book will teach you how to do data science with R..."
  ) %>% 
  meta_name("github-repo" = "hadley/r4ds") %>% 
  meta_viewport() %>% 
    title = "R for Data Science",
    url = "",
    image = "",
    image_alt = "The cover of the R4DS book",
    og_type = "book",
    og_author = c("Garrett Grolemund", "Hadley Wickham"),
    twitter_card_type = "summary",
    twitter_creator = "@hadley"
#> <meta name="viewport" content="width=device-width, initial-scale=1, orientation=auto"/>
#> <meta name="description" content="This book will teach you how to do data science with R..."/>
#> <meta name="github-repo" content="hadley/r4ds"/>
#> <meta name="twitter:title" content="R for Data Science"/>
#> <meta name="twitter:description" content="This book will teach you how to do data science with R..."/>
#> <meta name="twitter:url" content=""/>
#> <meta name="twitter:image" content=""/>
#> <meta name="twitter:image:alt" content="The cover of the R4DS book"/>
#> <meta name="twitter:card" content="summary"/>
#> <meta name="twitter:creator" content="@hadley"/>
#> <meta name="twitter:site" content="@hadley"/>
#> <meta property="og:title" content="R for Data Science"/>
#> <meta property="og:description" content="This book will teach you how to do data science with R..."/>
#> <meta property="og:url" content=""/>
#> <meta property="og:image" content=""/>
#> <meta property="og:image:alt" content="The cover of the R4DS book"/>
#> <meta property="og:type" content="book"/>
#> <meta property="og:locale" content="en_US"/>
#> <meta property="article:author" content="Garrett Grolemund"/>
#> <meta property="article:author" content="Hadley Wickham"/>

In Shiny Apps

To use metathis in Shiny apps, simply call meta() and related tags anywhere inside your page UI, for example inside fluidPage().

ui <- fluidPage(
  # Application title
  titlePanel("metathis Example"),
  meta() %>%
      title = "metathis",
      description = "<meta> and social media cards for web things in R",
      url = "",
      image = "",
      image_alt = "An image for social meda cards",
      twitter_creator = "@grrrck",
      twitter_card_type = "summary",
      twitter_site = "@grrrck"
  # ... your UI ...

In xaringan Slides

To use metathis in xaringan slides, add meta() and related tags in a chunk anywhere in your slide’s source .Rmd file. This example is from a presentation on the drake package.

```{r meta, echo=FALSE}
meta() %>%
    description = "A gentle introduction to reproducible data workflows with the {drake} package.",
    generator = "xaringan and remark.js"
  ) %>% 
  meta_name("github-repo" = "gadenbuie/drake-intro") %>% 
    title = "Reproducible Data Workflows With Drake",
    url = "",
    image = "",
    image_alt = "The first slide of the Reproducible Data Workflows with drake presentation, featuring the drake hex logo and neatly ordered row of items on a desk (eraser, pencil, coffee cup, paperclips).",
    og_type = "website",
    og_author = "Garrick Aden-Buie",
    twitter_card_type = "summary_large_image",
    twitter_creator = "@grrrck"


Thanks to Josh Buchea for providing an excellent and indispensable resource on <meta> tags and other things that go in the HTML <head> tags.

Thanks also to Malcolm Barret. Watching over his shoulder as he developed ymlthis made putting this package together so much easier.

Finally, thanks to the RStudio team and others who developed htmltools for making HTML in R a breeze.


  1. For adding meta tags to blogdown sites, Socialize your blogdown by Xavier A is an excellent resource and you can use metathis to help discover the tags you need while following the instructions in the article.