Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

Yihui’s minimal theme for blogdown is wonderful but the Academic theme by G. Cushen provides several benefits, the main one for me being the site is essentially a better-looking electronic CV. blogdown + hugo also makes it easy for me to add images and keep everything organized on a git repository from within RStudio.

Unlike many other themes, Academic has several different page types beyong the typical post such as project, and publication. Based on the assumption everything which should occur to post .Rmd files should also work with the project .Rmd files if they exist, I tried making a project file using .Rmd rather than the default .md.

posts usually have YAML frontmatter which can then be used by hugo. The typical YAML section on a post .Rmd looks like this.

---
title: Title of Post
author: First Last
date: 'YYYY-MM-DD'
slug: short-slug-to-use
categories:
- x
- y
- x
tags:
- a
caption: ''
image: ''
summary: "Short summary"
highlight: false
---



The summary is in addition to the automatic .Rmd generated through the new_post() addin. See here for why it is used.

The TOML front matter for a typical project page is (as taken from the Academic example site):

+++
date = 2016-04-27T00:00:00

# Project title.
title = "Deep Learning"

# Project summary to display on homepage.
summary = "Lorem ipsum dolor sit amet, consectetur adipiscing elit."

# Optional image to display on homepage (relative to static/img/ folder).
image_preview = "bubbles.jpg"

# Tags: can be used for filtering projects.
# Example: tags = ["machine-learning", "deep-learning"]
tags = ["Deep Learning"]

# Optional external URL for project (replaces project detail page).

# Does the project detail page use math formatting?
math = false

# Optional featured image (relative to static/img/ folder).
caption = "My caption ????"

+++


hugo can use both YAML and TOML but .Rmd files have to use YAML. We can start off a project Rmd file by converting all the TOML keys into YAML ones. Or copy the YAML front matter from a post .Rmd and delete the slug and author. As far as I’m aware, references to projects in the site occurs using the filename of the project file minus the extension.

---
title: "Deep Learning""
date: "2016-04-27""
summary: Lorem ipsum dolor sit amet, consectetur adipiscing elit."
image_preview: "bubbles.jpg"
tags: "Deep Learning"
math: false
image: "My caption ????"
---

Description of project and R code chunks go here.


Though I have not tested this, it should be possible to use .Rmd for the other page types in the Academic theme such as slides.

The motivating reason I tried to use .Rmd for a project file was actually because I wanted to embed a leaflet map for a project page. In regular Rmarkdown, this is down through the htmlwidgets package. To make sure the scripts associated with the widgets do not conflict with what is used in blogdown and hugo, there is the widgetframe package and a demo just for leaflet maps here.

In the process of creating the .html file from a .Rmd containing a htmlwidget, a new folder called rmakrdown-libs will be created in /static/. Make sure to also commit this folder to the git repository or else the widget will show up as a blank space.

My htmlwidget and the result of the .Rmd page for my project can be seen here