Insert tags in header via .Rmd

I am using Rstudio to generate Rmd reports and I would like to be able to insert meta tags in <head>

when Rmd is inserted in html.

From the documentation on knitr options it seemed to me that I could set the title option to insert text between tags <head>

like this:

```{r}
opts_knit$set(header = "<meta name=\"description\" content=\"this is a description\">")
```

      

However, nothing similar is inserted. Am I doing something wrong or is this not possible?

+2


source to share


1 answer


You are using a yaml header line that reads in an external .html file with your header snippet in the view at this link .

Below is a slight modification of the link that includes your code and includes the ability to create an external .html header in the .Rmd file, which is not required:



---
title: "Test"
output:
  html_document:
    includes:
       in_header: header.html
---

```{r setup, include=FALSE, echo=FALSE}
# Create header.html
CON <- file("header.html")
writeLines('<meta name="description" content="this is a description" />', CON)
close(CON)
```

      

0


source







All Articles