This is a (very basic) static website generator using R. There are many such generators, some of which handle R code. This is aimed at making R code a first class component of the site. It uses tools available as R packages.
A static website generator takes a bunch of files, usually written in various templating languages, and generates HTML webpages from it. Those HTML files can then be uploaded to any web server. This website generator supports R-centric templating languages (brew, Rmarkdown, Rhtml). In terms of how it works, in takes (heavy) inspiration from Middleman.
The package is not on CRAN (yet) but you can install it using the devtools package
library("devtools")
install_github("yssr", "jiho")
Load the package and initialise the website
library("yssr")
init("foo")
This creates a directory called foo
and sets your R working directory there. Inside foo
are:
source/layouts/main.brew
) which defines the skeleton of every page on your site.source/index.Rmd
) which contains the content of the future index.html
pageNow turn this into a website using
render()
This renders "index.Rmd" into HTML code which is then injected in the layout. The result is stored in the newly created build
directory, next to source
. To view this in a browser, provided you have python with SimpleHTTPServer, use:
serve()
The render functions does this sequence of things:
source
directorybrew
, Rmd
, Rhml
), render the content of each one and inject it into the layout. Store the resulting HTML files in the source directory.build
because they are not needed on the actual sitesource
directory, to come back to the state before 1.Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.