Blogdown R

Posted on  by admin
Blogdown

The RStudio community is a friendly place to ask any questions about blogdown. Be sure to use the blogdown tag. Stack Overflow is a great source of answers to common blogdown questions. Use the tags rblogdown if you ask a question. If you are interestend in how the website was created: I used an R package called blogdown - which uses hugo (https://gohugo.io/).

It was one of those rare moments in my freelance career when I had some extra time on my hands. Eager to work on a website and tinker with some code. I was looking at my personal website (which you’re on right now). It was still built on Wordpress, with a basic theme and some useful features. In reality, I wasn’t using much of the power that Wordpress holds. I didn’t use many of the extensions and plugins available and hardly any of the other features that were running on my website. Despite me not using the features, the website was pretty heavy on css and javascript libraries. Just a waste of bandwith and performance.

  • A guide to creating websites with R Markdown and the R package blogdown.
  • I’m a geographer whose work focuses on GIS and spatial analysis. I work primarily in R and Python using open source tools. This blog serves primarily to share new tools, tips and techniques I’ve.
  • I recommend that you install these R packages in advance: install.packages(c('rmarkdown', 'bookdown', 'blogdown', 'xaringan', 'pagedown', 'rticles', '.

I figured that based on my limited requirements, I could almost build a simple website based on some static HTML pages instead. After browsing the web looking for light-weight alternatives to Wordpress, I learned about Hugo and static website generators.

Introducing Hugo

Hugo considers itself to be “The world’s fastest framework for building websites”. Pretty bold claim, but as I looked into it some more I got kind of impressed. As a bonus, there are some additional benefits to using Hugo as a framework:

  • It integrates seemlessly with R, based on the Bookdown R package. And I like to write blogs with R code!
  • Hugo provides some useful basic plugins for features like an image gallery or comments plugin
  • Hugo is flexible, easy to configure and works based on templates you can edit to your hearts content
  • Hugo has an active open source community, ready to help out
  • Hugo provides sufficient options for templates. Not as many as a cms, but sufficient nonetheless
  • No underlying software to maintain
  • Easier access to the code under the hood
  • Security. No hacks into databases and other vulnerabilities
  • Write offline. You don’t have to login to your CMS admin to create pages
  • No server-side functionality which is needed for contact forms, comments, and search

My need for speed

Rstudio

One of my biggest frustrations with Wordpress must have been that it was stuffed with all these features and gizmos you never use, but they take up a lot of bandwith for users and make your website run slower than it has to be. It kind of reminded me of this scene from Psych. Shawn’s dad was clearly a wise man.

Why Hugo is super fast

Website performance matters. Even if I would selfishly ignore all other human visitors to my website, I would be supporting Google’s mission to make the web faster and help myself climb the ranks of Google.

Hugo is not a content management system (CMS). It is a static website generator. This means that it doesn’t reference a database to populate the page, but it creates each page individually and outputs the HTML you need. Whenever you want to write a new article, you write the content and Hugo will build the page. Hugo will include all the required references to CSS, javascript files and add other things required to render the page.

A static website generator like Hugo pre-renders pages and is generally faster than a classic CMS, which has to reference MySQL databases and process code when the browser loads.

Disadvantages to using Hugo

To be fair, Hugo does have some disadvantages in comparison to a CMS like Wordpress. Here are a few reasons you may want to consider sticking to your Wordpress environment:

  • Wordpress can be a code-free environment. If you are not very code savvy, this might be a big plus
  • The number of design templates for Hugo is limited to a couple of hundred. You may not find the one you like
  • You may need some fancy features that Hugo doesn’t support yet with their shortcodes

Getting started with Hugo

In case you’re interested in learning more about building your own website with Hugo, here are some of the resources I have used to build my website:

  • Hugo Website - useful as a startingpoint and general reference
  • The rise of static website generators - Read about the pros and cons of CMS vs static website generators
  • Blogdown book - This only book shares instructions on how to build your Hugo site with R
  • Blogdown Video - instruction video about using R and Hugo

Data Science

  • The Stats Geek: a blog on statistics
  • Cross Validated: probably the largest forum for discussing anything related to statistics and machine learning
  • Data Camp: a great resource for training in data science
  • Data Science Reader: an aggregator for data science content
  • DataTau: a data science forum
  • Data Science Hiring Guide: a practical guide on what to consider when hiring data scientists

Blogdown Github

R

Blogdown
  • RStudio Blog: keep up to date with the newest developments in RStudiodevelOverflow
  • Bioconductor: the repository for R packages relating to bioinformatics
  • R-bloggers: an aggregator for blog posts about R
  • Tidyverse: a highly useful collection of R package designed for data science of which ggplot2 and dplyr are probably the most notable members
  • Awesome R: ever wondered what great R packages are out there that you are not using? This curated list of R packages shows an overview of popular packages for various tasks.

Machine Learning

Blogdown R Hugo

  • The Elements Of Statistical Learning: the fundamental text book on statistical learning
  • Introduction to Statistical Learning: an introduction to statistical learning with applications in R

Programming

Pdf
  • Stack Overflow: if you have a programming problem, you’ll probably find the solution here
  • Introduction to Algorithms: a book providing a theoretical, comprehensive introduction to algorithms and data structures
  • Head First Design Patterns: a learner-friendly introduction to the most important design pattern
  • Clean Code: learn coding principles to become a clean coder

Blogdown Resources

Other

Rstudio Github

  • Awesome Blogdown: A curated list of static websuites built using the blogdown R package
  • rbind: A network of R bloggers

Is your favorite resource for data science missing? Let me know in the comments!