I Publish, therefore I Am
“No matter what happens in life, be good to people. Being good to people is a wonderful legacy to leave behind.”
— Taylor Swift
Setting up Git and GitHub
Windows: Head off https://gitforwindows.org and download and install the
git
app.MacOS: In a terminal type:
xcode-select --install
This will also install git.
Head off to https://github.com and register for an account. Make a note of your
emailID
and thepassword
used.Setup 2FA Authentication for GitHub based on instructions here: https://docs.github.com/en/authentication/securing-your-account-with-two-factor-authentication-2fa
Linking RStudio and GitHub (One Time Only)
- In RStudio, in your console:
install.packages(usethis)
library(usethis)
usethis::use_git_config(user.name = "Your Name", user.email = "Your Email ID used on GitHub")
- Generate a Personal Access Token(PAT) (One Time Only, usually)
usethis::create_github_token()
In the popup window, give your token a logical name you can remember(e.g. “For my Mac”), and remember why you created it. Check the scopes
of the PAT; the defaults are OK. Make sure selecting repo
, user
, and workflow
are checked. Save the PAT in your password manager. Default Expiry
is 30days; we can set the PAT to not expire too. (I have.)
- Let RStudio have your PAT (One Time Only, usually)
gitcreds::gitcreds_set()
and paste the PAT when asked.
- Check if all is OK using one or more of:
usethis::gh_token_help()
usethis::git_sitrep()
gh::gh_whoami()
- Check in RStudio if has automatically detected your Git installation.
Tools -> Global Options -> Git/SVN
The Git Executable
field should be like:
- Windows:
C:/Program Files/Git/bin/git.exe
. - MacOS:
/usr/bin/git
- Let RStudio know which project branch to commit/push to GitHub. ( Default is “main”)
usethis::git_default_branch_configure()
Creating your Blog Project in RStudio (One Time Only)
In the upper right corner of RStudio, click on:
Project -> New Project -> New Directory -> Quarto Blog
Name your Blog, browse to where you want the Blog Project Folder ( default is fine ). Check the Create a git repository
. Click Create Project
.
RStudio will restart with a new Blog Project. The Files pane should like this:
The posts
folder contains dummy blog posts, which you can retain for now and delete once your own content has matured.
Making your Blog ready to publish (Now, and every time you have new content)
In your Terminal:
quarto render
This will render all posts and prepare_site
and_freeze
folders in your Files tab. Check these.quarto preview
This will pop up your browser and show you a preview of your Blog website. Check the look and feel, the typos.
Pushing to GitHub
In your Console:
usethis::use_git()
: This will throw up a funky set of messages asking if you are ready tocommit
all files topush
to Github. Choose the appropriate reply and enter.usethis::use_github()
: This will create your new repository on Github andpush
all the committed files there. Your browser will open in Github and show you the contents of your new Blog repository.
Connecting to Netlify
Head off to https://www.netlify.com. Log in there with Github.
Click
Add new site -> Import from existing project
3. Choose Github
, then point to your Blog Github repo.
4.Give your Blog site a name: something-idiotic.netlify.app
. Check Availability.
Ensure that the branch says
main
, and that thePublish directory
says_site
.Hit
Deploy
. Netlify will ta ke a few minutes and then say the site is deployed. Click on the URL.There!
Adding Content and Updating
Create a new folder inside your
posts
folder. Name it something likenew-post-todays-date
. Hyphens only, no underscores.Create a new Quarto Document:
File -> New-File -> New Quarto Document
. Save it asindex.qmd
inside your just-creatednew-post-todays-date
folder.
Edit / Write up your Post. Add pictures, videos, code, visualizations, explanations. Use <quarto.org> to find other Markdown constructs ( tabs , asides, marginal content..) and complete your post.
In your Terminal, run
quarto render
to update your_site
and_freeze
folders.In your Terminal run
quarto preview
to check if your new post previews properly.Instead of using the Terminal, or the Git pane in Rstudio, there is a better way. This is a GUI, and one can see the files, the history of commits/pushes, the commit messages, revert back to a point in history, make brances…all that visually, without some tough-looking git commands,
- So,Install a git client, such as Gitkraken.
- It offers a ready prompt to log in with Github, accept that, filling in ID and password.
- Open
File ->New tab
->Browse for Repo
and browse to your Blog project folder (which is what you open in RStudio) - You will a list of previous commits, and a bunch of new edited/ changed files which are default labelled
WIP
.
- Click on
Stage All
and type in a memorablecommit
message in the box below at right. - The
WIP
will be replaced by yourcommit message
. - Once
staging
is done, hit thePush
button on the main tool bar. - After Gitkraken is done, a brief popup will show stating
push
was successful. - Your website should be updated in a few minutes.
Yeah, peasants, you’re welcome.
Workflow Diagram
References
Citation
@online{v2024,
author = {V, Arvind},
title = {\textless Iconify-Icon Icon=“entypo:publish” Width=“1.2rem”
Height=“1.2rem”\textgreater\textless/Iconify-Icon\textgreater{} {I}
{Publish,} Therefore {I} {Am}},
date = {2024-06-23},
url = {https://av-quarto.netlify.app/content/courses/Analytics/Workflow/Modules/30-BlogSite/},
langid = {en},
abstract = {Putting it all out there on the web}
}