Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/jumpingrivers/headR

Adding meta cards to Rmd files
https://github.com/jumpingrivers/headR

knitr rmd-document rstats

Last synced: 3 months ago
JSON representation

Adding meta cards to Rmd files

Awesome Lists containing this project

README

        

---
output:
md_document:
variant: markdown_github
editor_options:
chunk_output_type: console
---

```{r, echo = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "README-"
)
```

# HeadR

[![Build Status](https://travis-ci.org/jumpingrivers/headR.svg?branch=master)](https://travis-ci.org/jumpingrivers/headR)

__headR__ is an R package for creating html summary cards for your R markdown files. These cards
are located in the meta tags of generated HTML document and allow you add richer
content when sharing your site.

To install the package, you need the __devtools__ package
```{r, eval = FALSE}
devtools::install_github("jumpingrivers/headR")
```

## Twitter Cards

When a URL is shared on twitter, the web page is parsed to determine if
a [twitter card](https://developer.twitter.com/en/docs/tweets/optimize-with-cards/guides/getting-started.html) is present.

For example, the following pages have twitter cards:

* [Twitter card](https://www.jumpingrivers.com/rpackages/headr/vignettes/twitter_large.html)
* [Twitter card + Slides](https://www.jumpingrivers.com/rpackages/headr/vignettes/twitter_slides.html)

To preview the twitter card for these document, simply copy and paste the page URL into the [twitter card validator](https://cards-dev.twitter.com/validator).

When the links are shared via twitter, the bespoke card is displayed!

## The package

HeadR currently supports two types of meta tags: twitter and open graph. Usually you would have to write meta tags within your html file for them to have a visually appealing sharing format. An example of how you would add these meta tags to your Rmd document is as shown:

```
---
output:
html_document:
includes:
in_header: twitter_card.html
---
```

The file `twitter_card.html` contains meta tag information is the output of running the function `headR::add_twitter_card()`. More specifically:

```{r, eval = FALSE}
headR::add_twitter_card(title = "This is the title!",
file = "twitter_card.html",
image = "http://www.example.com/path.jpg")
```

---

Development of this package was supported by [Jumping Rivers](https://www.jumpingrivers.com/)