+ - 0:00:00
Notes for current slide
Notes for next slide

Lab 07: CS631

Making a Site in the Tada!-verse
Part Deux: Make a Shareable Site

Alison Hill

1 / 29

First:

Build a site with blogdown

2 / 29

First:

Build a site with blogdown

Pre-work:

Push to GitHub

2 / 29

First:

Build a site with blogdown

Pre-work:

Push to GitHub

NOW!:

Deploy to Netlify!

2 / 29

Your pre-work

http://happygitwithr.com

3 / 29

"As we just mentioned, Netlify allows you to quickly publish a website by uploading the public/ folder through its web interface, and you will be assigned a random subdomain *.netlify.com. This approach is good for those websites that are not updated frequently (or at all)."

https://bookdown.org/yihui/blogdown/netlify.html

4 / 29

If you didn't do the pre-work...

  • Drag + drop your public/ folder.

  • If you did, follow me!

5 / 29

Go to Netlify.com

http://netlify.com

6 / 29

Click on "Sign up"

7 / 29

Select "GitHub"

click to "Authorize Netlify"

Recommended: go through the quick start guide

8 / 29

Netlify review so far

  1. Sign up
  2. Pick GitHub
  3. Authorize Netlify
  4. Go through the quick start guide
9 / 29

Two ways to make a new site

10 / 29

New site

If you did the pre-work

  • Select "New site from Git"
  • Under continuous deployment, pick GitHub
11 / 29

New site from Git

  • Click to authorize Netlify
  • Confirm GitHub password
  • Pick your blogdown repository

12 / 29

Build options

  1. Leave branch to deploy as master
  2. The build command is hugo
  3. The publish directory is public

13 / 29

Go back to your R project

In R console type:

blogdown::hugo_version()
[1] '0.41'
14 / 29

Go back to Netlify in browser

  1. Click show advanced
  2. Create a new variable:
    • the key is HUGO_VERSION
    • the value is 0.40
  3. Click deploy site
15 / 29

16 / 29

From Netlify

  • Click on Site Settings (from overview) --> general

  • Click on change site name and try to find a unique one- it will change your domain name to [your-new-site-name].netlify.com

17 / 29

Go back to your R project

  • Open up config.toml and update your baseurl = "https://[your-new-site-name].netlify.com/"

    • The final / is critical!
  • Save

  • Serve your site (if you haven't done this already!)

  • Commit

  • Push to GitHub

18 / 29

Now go to your site!

19 / 29

Add your xaringan slides

https://blogdown-demo.rbind.io/2017/09/06/adding-r-markdown-documents-of-other-output-formats/

  1. Go to your blogdown project’s root directory and create a new folder called R
  2. In that R/ directory, create a new R script called build.R that contains 1 line of code that reads: blogdown::build_dir('static')
  3. Add and save Rmd file(s) to your blogdown project in a new static/slides/ directory.
  4. Serve your site (if you haven't done this already!)

20 / 29

Now that your xaringan slides are being rendered by blogdown, we have to link to them! If you placed them in static/slides/, then you should be able to navigate to the rendered slides at:

  • [your-new-site-name].netlify.com/slides/[name_of_deck].html

But you can use relative links in your blogdown site using Markdown links:

  • Here are some of my [slides](slides/slides.html)

blogdown assumes that relative links start in the static/ directory.

21 / 29

I added a Markdown link to my /content/home.md using this line:

  • Here are some of my [slides](slides/slides.html)

22 / 29

⚠️

Going further...

You have gone far enough- you don't have to do what is next!

23 / 29

Embed slides within an .Rmd post

You can embed your xaringan slides within an .Rmd blog post. Steps:

  • Go to content/blog/2015-07-23-r-rmarkdown.Rmd (this is just the sample blog post)

  • Add an R code chunk and use knitr::include_url

knitr::include_url("../../slides/slides.html")
  • Why this particular file path? Because knitr uses the starting directory as where your post lives, so content/blog/.
    • The second ../ gets you up one directory, to content/
    • The first ../ gets you up one more directory level, to your project root directory
24 / 29

View embedded slides

25 / 29

Demo to override CSS

26 / 29
  1. Make a new static/css/ directory
  2. Make a new text file in that directory, I called mine circle.css and put this inside
div.header .container .logo {
max-width: 100px;
margin-left: -2em;
border-radius: 50%;
}
27 / 29

Demo to override CSS

Go back to the config.toml

[params]
dateform = "Jan 2, 2006"
dateformfull = "Mon Jan 2 2006 15:04:05 MST"
description = "Example blog"
copyright = "Copyright © 2015 Ada Lovelace"
# copyrightUrl = "https://creativecommons.org/licenses/by-sa/4.0/"
logofile = "img/logo.jpg"
faviconfile = "img/logo.png"
highlightjs = true
progressively = true
share = true
extracssfiles = [ "/css/circle.css" ]
28 / 29

Override CSS

How did I know to do this? A lot of googling. I finally found an example config.toml for the parent theme, Cocoa, here:

29 / 29

First:

Build a site with blogdown

2 / 29
Paused

Help

Keyboard shortcuts

, , Pg Up, k Go to previous slide
, , Pg Dn, Space, j Go to next slide
Home Go to first slide
End Go to last slide
Number + Return Go to specific slide
b / m / f Toggle blackout / mirrored / fullscreen mode
c Clone slideshow
p Toggle presenter mode
t Restart the presentation timer
?, h Toggle this help
Esc Back to slideshow