9

I have a knitr program that renders to html in a browser page. Id like to put a favicon .png image in the browser tab that the output opens up to.

I have seen answers for this with shiny, but not standalone knitr

Favicon in Shiny

Yihui Xie
  • 28,913
  • 23
  • 193
  • 419
Rhodo
  • 1,234
  • 4
  • 19
  • 35

1 Answers1

11

In order to get a favicon, you have to insert the following HTML element in the <head> element of the rendered document:

<link rel="shortcut icon" href="link_to_your_favicon.png">

There are many methods to achieve this goal.
I recommend to use the includes option.

For instance, save the following line in a file named favicon.html:

<link rel="shortcut icon" href="https://www.r-project.org/favicon-32x32.png">

If you render the following Rmd document, you will get a HTML file with the R project's favicon:

---
title: "Favicon"
output: 
  html_document:
    includes:
      in_header: "favicon.html" 
---

A document with a favicon
RLesur
  • 5,810
  • 1
  • 18
  • 53