class: center, middle, inverse, title-slide # > ย ย 04 ๐
> ย ย website <- blogdown + github ## ๐ ย
robust-tools.djnavarro.net
### danielle navarro --- layout: true <div class="my-footer"> <span> <a href="https://robust-tools.djnavarro.net" target="_blank">robust-tools.djnavarro.net</a> </span> </div> --- class: middle, inverse .pull-left-narrow[ .huge-bisque-number[1] ] .pull-right-wide[ <br><br><br> .larger[.embolden[GitHub]] <img src="img/git_commits.png" width="579" /> ] --- class: middle ## https://github.com - **git**: software to help you organise your code (more later!) - **GitHub**: a website for sharing and collaborating code (using git) --- class: middle ## Me... https://github.com/djnavarro .pull-left[ <img src="img/djnavarro_github.png" width="652" /> ] --- class: middle ## Also me... https://github.com/stringrbelle .pull-left[ <img src="img/stringrbelle_github.png" width="648" /> ] --- class: middle, inverse <img src="img/stringrbelle_avi.png" width="55" /> oh hey you have a code repository I would like to use! <img src="img/djnavarro_avi.jpeg" width="55" /> really, which one? <img src="img/stringrbelle_avi.png" width="55" /> this one! https://github.com/djnavarro/newblog <img src="img/djnavarro_avi.jpeg" width="55" /> oh cool. well, you're always welcome to create your own **fork** of the repo. or you can use this one as a **template** for your own if you like! <img src="img/stringrbelle_avi.png" width="55" /> awesome! now, how do i do this?? --- class: middle, inverse .hand[Create your own!] - https://github.com/djnavarro/newblog - create your repository using "djnavarro/newblog" as a template - use your respository to create a new RStudio cloud project --- ## 1. go to the "newblog" repository<br>https://github.com/djnavarro/newblog <img src="img/github_template2.png" width="768" /> --- ## 2. create "waffle-blog" from the template <img src="img/github_template3.png" width="783" /> --- ## 3. copy link to the "waffle-blog" repo <img src="img/github_template4.png" width="906" /> --- ## 4. go to https://rstudio.cloud<br>then click the arrow next to "new project"<br><br> <img src="img/rstudiocloud_template.png" width="1000" /> --- ## 5. create new project from your repo<br><br> <img src="img/rstudiocloud_template2.png" width="1015" /> --- ## 6. celebrate with cake ๐ฐ ๐ <img src="img/rstudiocloud_template3.png" width="1019" /> --- class: middle, inverse .pull-left-narrow[ .huge-bisque-number[2] ] .pull-right-wide[ <br><br><br> .larger[.embolden[Blogdown]] <img src="img/blogdown.png" width="212" /> ] --- class: middle, inverse ## Frankenstein's monster - **Markdown:** a simple text-only format for writing documents - **R markdown:** a tool for mixing R code with markdown - **Blogdown:** a tool for writing blogs using R markdown - **Hugo:** a vile demon that blogdown summons to do its magic --- class: inverse ## Building the blog .pull-left[ ```r library(blogdown) serve_site() ``` ] -- .pull-right[ <img src="img/blog_00.png" width="777" /> ] --- class: inverse ## Making a new_post() <img src="img/blog_02.png" width="922" /> --- class: inverse ## Editing the document <img src="img/blog_03.png" width="2642" /> --- ## Some markdown .pull-left[ ``` Markdown: - unnumbered lists - look like this 1. numbered lists 2. look like this this is *italicised* this is **boldfaced** ``` ] -- .pull-right[ Output: - unnumbered lists - look like this 1. numbered lists 2. look like this this is *italicised* this is **boldfaced** ] --- ## Some markdown .pull-left[ ``` # Level 1 heading ## Level 2 heading ### Level 3 heading ``` ] -- .pull-right[ # Level 1 heading ## Level 2 heading ### Level 3 heading ] --- ## Some markdown .pull-left-wide[ ``` To insert an image: ![](https://placekitten.com/200/400) ``` ] -- .pull-right-narrow[ To insert an image: ![](https://placekitten.com/200/400) ] --- ## Some markdown .pull-left-wide[ ``` To insert a URL: https://placekitten.com To make a named link: [Placekitten](https://placekitten.com) ``` ] -- .pull-right-narrow[ To insert a URL: https://placekitten.com To insert a named link: [Placekitten](https://placekitten.com) ] --- ## Some markdown .pull-left[ ``` To insert a LaTeX equation: $$ a^2 + b^2 = c^2 $$ ``` ] -- .pull-right[ To insert a LaTeX equation: $$ a^2 + b^2 = c^2 $$ ] --- class: middle, inverse .hand[Create your own!] - write a short blog post (and save it) - try to use a few markdown features --- class: middle, inverse .pull-left-narrow[ .huge-bisque-number[3] ] .pull-right-wide[ <br><br><br> .larger[.embolden[Push and Publish]] ] --- .pull-left-wide[ <img src="img/Publish1.png" width="712" /> ] .pull-right-narrow[ .xsmall[ 1. djnavarro creates the `newblog` repository on github<br><br> ] ] --- .pull-left-wide[ <img src="img/Publish2.png" width="712" /> ] .pull-right-narrow[ .xsmall[ 1. djnavarro creates the `newblog` repository on github<br><br> 2. djnavarro publishes `newblog` to github pages<br><br> ] ] --- .pull-left-wide[ <img src="img/Publish3.png" width="712" /> ] .pull-right-narrow[ .xsmall[ 1. djnavarro creates the `newblog` repository on github<br><br> 2. djnavarro publishes `newblog` to github pages<br><br> 3. stringrbelle creates `waffle-blog` from djnavarro's template<br><br> ] ] --- .pull-left-wide[ <img src="img/Publish4.png" width="712" /> ] .pull-right-narrow[ .xsmall[ 1. djnavarro creates the `newblog` repository on github<br><br> 2. djnavarro publishes `newblog` to github pages<br><br> 3. stringrbelle creates `waffle-blog` from djnavarro's template<br><br> 4. stringrbelle creates rstudio cloud project from `waffle-blog`<br><br> ] ] --- .pull-left-wide[ <img src="img/Publish5.png" width="712" /> ] .pull-right-narrow[ .xsmall[ 1. djnavarro creates the `newblog` repository on github<br><br> 2. djnavarro publishes `newblog` to github pages<br><br> 3. stringrbelle creates `waffle-blog` from djnavarro's template<br><br> 4. stringrbelle creates rstudio cloud project from `waffle-blog`<br><br> 5. stringrbelle modifies `waffle-blog` project on rstudio cloud<br><br> ] ] --- .pull-left-wide[ <img src="img/Publish6.png" width="712" /> ] .pull-right-narrow[ .xsmall[ 1. djnavarro creates the `newblog` repository on github<br><br> 2. djnavarro publishes `newblog` to github pages<br><br> 3. stringrbelle creates `waffle-blog` from djnavarro's template<br><br> 4. stringrbelle creates rstudio cloud project from `waffle-blog`<br><br> 5. stringrbelle modifies `waffle-blog` project on rstudio cloud<br><br> 6. stringrbelle wants to **push** changes to github and **publish** to github pages <br>(... but how?) ] ] --- class: middle, inverse .hand[first, a demonstration...] --- class: middle, inverse .hand[now, a recap...] --- class: .hand[Step 1: Staging changes...] .pull-left-narrow[ .small[ - **stage**: tells git *which* changes to include<br><br> - go to the git pane - shows list of files that have changed - click "commit" to open the commit window... ] ] .pull-right-wide[ <img src="img/git_push1.png" width="513" /> ] --- .hand[Step 1: Staging changes...] .pull-left-narrow[ .small[ - commit window `->` - shows changes in detail ] ] .pull-right-wide[ <img src="img/git_push2.png" width="886" /> ] --- .hand[Step 1: Staging changes...] .pull-left-narrow[ .small[ - to select one file to stage, click its checkbox<br><br> - to stage everything all at once, use shortcut key (ctrl-A, cmd-A on Mac) to select all, then check any of the boxes (will stage all of them) ] ] .pull-right-wide[ <img src="img/git_push3.png" width="884" /> ] --- .hand[Step 2: Commiting changes...] .pull-left-narrow[ .small[ - **commit**: to make a permanent addition to the local repository (i.e., on rstudio cloud) <br><br> - write a descriptive "commit message" - then click "commit"... ] ] .pull-right-wide[ <img src="img/git_push4.png" width="885" /> ] --- class: inverse .hand[Something goes wrong...] .pull-left-narrow[ .small[ - oh noes!<br><br> - don't stress! - making mistakes with git is *very* common<br><br> - in this case, the local copy of git (on rstudio cloud) doesn't know who we are - okay... open the `git_config.R` script! ] ] .pull-right-wide[ <img src="img/git_push6.png" width="573" /> ] --- class: inverse .hand[Something goes wrong...] .pull-left-narrow[ .small[ - stringrbelle types her email and name - she sources the script... <br><br> - then tries again! ] ] .pull-right-wide[ <img src="img/git_push7.png" width="490" /> ] --- .hand[Step 2: Commiting changes...] .pull-left-narrow[ .small[ - back to the commit! - type informative message - click "commit"... ] ] .pull-right-wide[ <img src="img/git_push8.png" width="886" /> ] --- .hand[Step 2: Commiting changes...] .pull-left-narrow[ .small[ - yaaaay! - the *local* (rstudio) repository now has the "commit" - click "close"<br><br> - next step is to "push"... press "push" ๐ ] ] .pull-right-wide[ <img src="img/git_push9.png" width="886" /> ] --- .hand[Step 3: Pushing the commit...] .pull-left-narrow[ .small[ - **push**: send commit(s) from the local repository (on rstudio cloud) to the remote version (on github)<br><br> - press the "push" button - stringrbelle needs to enter her github user name and password ] ] .pull-right-wide[ <img src="img/git_push10.png" width="885" /> ] --- .hand[Step 3: Pushing the commit...] .pull-left-narrow[ .small[ - yaaay! ]] .pull-right-wide[ <img src="img/git_push11.png" width="570" /> ] --- .hand[Step 3: Pushing the commit...] .pull-left-narrow[ .small[ - here's what stringrbelle's repository looked like before ] ] .pull-right-wide[ <img src="img/git_push5.png" width="524" /> ] --- .hand[Step 3: Pushing the commit...] .pull-left-narrow[ .small[ - here's what it looks like after!<br><br> - for the next step, click "settings" ] ] .pull-right-wide[ <img src="img/git_push12.png" width="509" /> ] --- .hand[Step 4: Publishing the blog...] .pull-left-narrow[ .small[ - output is in "docs" - to publish, stringrbelle needs to enable GitHub Pages for this repo - only needs to do it once: later changes are published automtically<br><br> - under settings, scroll down to "GitHub Pages" - under "source" menu, choose "master branch /docs folder" ] ] .pull-right-wide[ <img src="img/git_push13.png" width="404" /> ] --- .hand[Step 4: Publishing the blog...] .pull-left-narrow[ .small[ - she has a website now! - click on the link and... ] ] .pull-right-wide[ <img src="img/git_push14.png" width="397" /> ] --- .hand[Step 5: Celebrate! Eat cake! ๐ ๐ฐ] <img src="img/git_push15.png" width="886" /> --- class: middle, inverse .pull-left-narrow[ .huge-bisque-number[4] ] .pull-right-wide[ .larger[.embolden[ oh no ๐ฑ<br> <img src="img/hugo-logo-wide.png" width="478" /> ]]] --- class: inverse .hand[Our blog comes with some tutorials!] <img src="img/tutorial.png" width="489" /> --- class: inverse .hand[Let's have a look at our files...] .pull-left-wide[ - files used by github or our rstudio project - `newblog.Rproj` - `install_packages.R` - `git_config.R` - `.gitignore` - `.Rhistory` ] .pull-right-narrow[ <img src="img/files1.png" width="316" /> ] --- class: inverse .hand[Let's have a look at our files...] .pull-left-wide[ - `content`: (R) markdown files for the blog - `docs`: generated output files (the website!) - `layouts`: customise your own layouts - `static`: image files and other resources - `themes`: files used by Hugo (don't touch!) ] .pull-right-narrow[ <img src="img/files2.png" width="316" /> ] --- class: inverse .hand[Let's have a look at our files...] .pull-left-wide[ - `index.Rmd`: file used by blogdown (boring) - `config.toml`: user settings for the blog (hello sweetie!) ] .pull-right-narrow[ <img src="img/files3.png" width="316" /> ] --- class: inverse .hand[Let's have a look at our files...] <img src="img/config-toml.png" width="821" /> --- class: middle .hand[Let's tinker with it...] --- .hand[Editing "params" and deleting a "menu" item...] <img src="img/blog_edits2.png" width="775" /> <img src="img/blog_edits1.png" width="778" /> --- .hand[Editing "content/_index.Rmd" for the front page] <img src="img/blog_edits3.png" width="1311" /> --- .hand[Stage, commit and push to publish] .pull-left[ - A lot of things have changed! - When you're happy, follow the same process as before to publish the changes ] .pull-right[ <img src="img/blog_edits4.png" width="414" /> ] --- class: middle background-image: url("img/scope_03.png") background-size: cover .pull-left[ <h3><a style="color:black;font-weight:900;font-size:120%" href=https://stringrbelle.github.io/waffle-blog/>stringrbelle.github.io/<br>waffle-blog</a></h3> ] --- class: middle, inverse .pull-left-narrow[ .huge-bisque-number[5] ] .pull-right-wide[ .larger[.embolden[R chunks <img src="img/rmarkdown.png" width="212" /> ]]] --- .hand[Create a new post...] .pull-left-wide[ ```r new_post( title = "Using R Markdown", author = "Stringr Belle", ext = ".Rmd" ) ``` ] .pull-right-narrow[ <img src="img/rmd1.png" width="363" /> ] --- .hand[Add some markdown...] <img src="img/rmd2.png" width="1320" /> --- .hand[Add an R chunk...] <img src="img/rmd3.png" width="1320" /> --- .hand[Make the R chunk prettier...] <img src="img/rmd4.png" width="1322" /> --- .hand[Add some familiar ggplot2 code...] <img src="img/rmd5.png" width="1317" /> --- .pull-left-narrow[ <br><br><br><br><br> ## ๐ ๐ฐ ] .pull-right-wide[ <img src="img/rmd6.png" width="655" /> ] --- class: inverse background-image: url("img/waffles.jpg") background-size: cover <h2><a href="https://stringrbelle.github.io/waffle-blog/" style="color:white">https://stringrbelle.github.io/waffle-blog/</a></h2>