class: center, middle, inverse, title-slide # Making Websites with R Markdown ## A Sneak Peek of blogdown ###
Yihui Xie, RStudio
### 2017/01/14 @ rstudio::conf, Kissimmee, FL --- # Demo - https://github.com/rstudio/blogdown (early beta!!) - If you use RStudio, create a new empty project; if not, `setwd()` to an empty directory first. ```r devtools::install_github('rstudio/blogdown') # automatically install Hugo, create a site, download a theme, # add sample posts, and start a local web server blogdown::new_site() ``` - If you have RStudio [>= v1.1.28](https://dailies.rstudio.com), you can create a website project via `File -> New Project`. ??? Agile development. Test-driven. RStudio is conference-driven. --- background-image: url(https://www.rstudio.com/wp-content/uploads/2015/12/RStudio_Hex_rmarkdown.png) background-size: 10% background-position: 90% 5% # Why R Markdown? > R Markdown is the new PHP. > .right[-- Yihui-Down, 2015] -- ![](gif/rpress.jpg) ??? - If you have read the knitr book, you will find I mentioned PHP on page 1 - R for statistics and data analysis; Markdown for simplicity - The initial discussion in May 2015 --- background-image: url(https://gohugo.io/img/hugo.png) background-size: 10% background-position: 90% 5% # Why Hugo? - We love static web pages (in theory, we could make Rmd the new PHP, i.e. a dynamic server-side "language", but the gain may be trivial) - Nearly 15,000 stars on Github - A single binary like Pandoc (easy to install: `blogdown::install_hugo()`) - Markdown support -- - Fast -- so fast that it makes me feel guilty since **blogdown** is not as fast - I imagine there will be some optimization work for me to do in the near future --- # Why yet another package, blogdown? .center[ <img src="gif/disguised-cat.jpg" width=400 /> ] -- - Hugo has pretty much everything we need (Markdown, templates, themes, and so on) -- - except R Markdown<sup>*</sup> .footnote[[*] Sometimes I feel I'm just like an R Markdown virus.] --- # A brief intro to a Hugo website - directory structure - `content/` - `about.md` - `post/` - `themes/`: there may be multiple themes - `static/`: copied to `public/` (think the `inst/` directory of an R source package) - `public/`: the generated website that can be uploaded to any web server (Github pages, Amazon S3, ...) - a Markdown file or an R Markdown file - YAML metadata (title, author, date, tags, ...) - body --- background-image: url(https://images.unsplash.com/photo-1424460421773-58b49adfc68a?dpr=2&auto=format&fit=crop&w=1500&h=1000&q=80&cs=tinysrgb&crop=) background-size: cover class: inverse # blogdown - blogdown ≈ Hugo + R Markdown - Hugo can only process Markdown; R Markdown is prebuilt to `.html` and passed to Hugo - a few helper functions - `new_site()` creates a new website - `install_hugo()` / `install_theme()` - `serve_site()` rebuilds and live reloads a website on changes (RStudio addin "Live Preview Site") - `new_post()` creates a new post under `content/post/` and automatically fills out some YAML metadata (title, author, date, ...) - output format: `blogdown::html_page` - built on top of `bookdown::html_document2`, so most [**bookdown**](https://bookdown.org) features are also available in **blogdown** --- # RStudio IDE support - The "Live Preview Site" addin - The "New Post" addin - New website project (daily build!) --- background-image: url(gif/dog-drag.gif) background-size: 50% # Please go ahead and test it --- background-image: url(gif/logo.png) background-position: 90% 50% background-size: 20% # Contact info - Yihui Xie - https://yihui.org - Twitter [@xieyihui](https://twitter.com/xieyihui) Github [@yihui](https://github.com/yihui) - RStudio - https://www.rstudio.com - Twitter [@rstudio](https://twitter.com/rstudio) Github [@rstudio](https://github.com/rstudio)