Ian Wesley
Ian Wesley

Reputation: 3624

R Markdown Add Tag to Head of HTML Output

How do I add an HTML meta tag within the head of an RMarkdown HTML output file from RStudio?

In particular I am trying to insert the following to over come IE compatibility issues on our intranet.

<head>
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
</head>

Upvotes: 12

Views: 4336

Answers (2)

IVIM
IVIM

Reputation: 2367

Use library(metathis) !

Then include with:

```{r include=F}
meta() %>%
  meta_description("My awesome App")
```

And any other meta tag

Upvotes: 4

Marcelo
Marcelo

Reputation: 4282

You can create a file with the meta tag and add using the following YAML option:

---
title: "mytitle"
output:
  html_document:
    includes:
       in_header: myheader.html
---

You could also create the myheader.html file on the fly in the setup chunck:

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = FALSE )
#libraries
require(ggplot2)

#Create myheader.html
fileConn <- file("myheader.html")
writeLines('<meta http-equiv="X-UA-Compatible" content="IE=edge" />', fileConn)
close(fileConn)
```

Upvotes: 10

Related Questions