Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I add a favicon to Knitr html browser tab output in R?

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

like image 710
Rhodo Avatar asked Jul 18 '18 14:07

Rhodo


1 Answers

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
like image 71
RLesur Avatar answered Nov 17 '22 19:11

RLesur