This is an incredibly easy way to spice up any R Markdown file. It adds an animated link to GitHub in the top corner of the HTML output, just like you see at the top of this page. Mouse over the icon to make it wave. All thanks and praise should go to the creator
The first step is to create a new file called “header.html” and paste in the following code (alternatively, you can right-click here, download this file, and place it in the same directory as the R Markdown). This creates a blue icon, though the background color and GitHub figure color can be changed at
style="fill:#1E80F0; color:#fff, in that order. You’ll also want to change the link URL at the very begining of the code:
Then, in the YAML header of the R Markdown, tell it to inlcude the new file at the beginning of the output HTML.
--- title: "Title of R Markdown" author: Joshua Cook date: 2019-08-16 output: html_document: includes: in_header: header.html ---
That’s it! It is really that simple to use.
NB. If there is navigation bar at the top of the HTML file (if you are using ‘
pkgdown‘, for instance), you will need to adjust the top position of the GitHub corner, manually. This can be done by adjusting the values in
position: absolute; top: 0; border: 0; right: 0;, where a positive value for
top will move the corner down.