Skip to content

Blogdown workflow

Enrico Spinielli edited this page Mar 20, 2020 · 3 revisions

Setup

Packages

You need to have installed the following packages:

  • blogdown
  • bookdown
  • tidyverse
  • servr

Options

You can override the project blogdown options in <project root>.Rprofile by defining them in your ~/Rprofile, see D1 section in the blogdown book.

The project is setup to have the generated HTML file put in ../pru-portal-generated, so in the folder pru-portal-generated one level up compared to the project folder. This makes your RStudio IDE much more responsive when the project is under version control and contains many many files (see D1 section in the blogdown book.)

Setup / initialization

Hugo

  1. Download the hugo version you want to use (see also netlify.toml to test and define the hugo version for the different Deploy Contexts)

  2. On MS Windows work laptop copy the hugo.exe in the <home>/dev/

  3. set the blogdown.hugo.dir option accordingly, see Appendix D 1 of the Blogdown book.

Local setup

Clone the repo (AND submodules) to pru-portal

# clone the pru portal repo AND submodules
$ cd repos
$ git clone --recurse-submodules https://github.com/euctrl-pru/portal/ pru-portal
# create the directory where the generated HTML will be written
$ mkdir pru-portal-generated

IF you FORGOT to include the theme submodule:

$ cd repos/pru-portal
$ git submodule update --init

If you have hugo installed separately that via blogdown default location, you can specify where to find it via options (better to set it in .Rprofile, see Blogdown boo):

options(blogdown.hugo.dir = '/Users/espin/go/bin/')

Workflow

Serve your web site

  1. In a Git for Windows terminal, go to the PRU website directory

    $ cd /c/repos/pru-portal
  2. Move to the directory where HTML files will be generated

    $ cd ../pru-portal-generated
  3. Run a webserver

    $ Rscript -e 'servr::httd()'

Edit your web site

Within RStudio create or edit Rmd/md files and once ready build the site (only modified files will be regenerated):

> blogdown::build_site(local = TRUE)