-Box
├── Box
├── github ├── kellyshee.github.io
You need the following:
This website’s directory is kellyshee.github.io
. The directory in the images is quarto_web_tutorial
, which I deleted because I dislike underscores in URLs.
1 Create a R project
- Navigate to File > New Project > New Directory > Quarto Website.
- Directory name
- If this website is for . . .
- yourself:
your-github-username.github.io
- class:
your-class-name
- yourself:
- If this website is for . . .
- Create project as subdirectory
- Where do you want to place this project? It should be somewhere easy to find, such as on your desktop.
- I’ll be creating more version-controlled projects, so I placed this directory (
kellyshee.github.io
) inside a “github” folder, which is located inside my Box drive. Therefore, this directory’s file path is the following:
- Engine: Knitr
- Select Create a git repository
- Select Use renv with this project
2 Create a GitHub repo
- Go to GitHub.
- Click the green “New” button next to “Top repositories” in the left column.
- Type your repository name, which must be the same as your directory name.
- Do not change anything else. Scroll down to create your repository.
3 Copy Git commands
4 Paste Git commands into terminal
5 Push local files to repo
- Copy and paste the following commands one by one into the terminal. Output will apppear, indicating that files are being uploaded to your repository.
Terminal
git add .-m "Initial commit"
git commit git push origin main
- Return to your GitHub repository and refresh the page. Your project’s files should appear there.
6 Create gh-pages branch
7 Create automation file
- Return to RStudio and navigate to the file tab in the output pane.
- Create a new folder named
.github
- Inside the
.github
folder, create another new folder namedworkflows
- Inside the
workflows
folder, create a text file namedpublish.yml
.
The file path of publish.yml
should be the following:
├── ...
├── kellyshee.github.io
├── kellyshee.github.io.Rproj
├── other files
├── .github
├── workflows ├── publish.yml
8 Copy and paste code into publish.yml
Paste the following code into publish.yml
, then save the file.
.github/workflows/publish.yml
# Knitr with renv
:
on:
workflow_dispatch:
push: main
branches
: Quarto Publish
name
:
jobs-deploy:
build-on: ubuntu-latest
runs:
permissions: write
contents:
steps- name: Check out repository
: actions/checkout@v4
uses
- name: Set up Quarto
: quarto-dev/quarto-actions/setup@v2
uses
- name: Install R
: r-lib/actions/setup-r@v2
uses:
with-version: '4.2.0'
r
- name: Install R Dependencies
: r-lib/actions/setup-renv@v2
uses:
with-version: 1
cache
- name: Render and Publish
: quarto-dev/quarto-actions/publish@v2
uses:
with: gh-pages
target:
env: ${{ secrets.GITHUB_TOKEN }} GITHUB_TOKEN
9 Push publish.yml to repo
10 Check repo settings
- Return to GitHub.
- Click on the Actions tab. Wait until all actions are green.
- Click on the “Settings” tab. Look at the side column and click “Pages.” Ensure that your GitHub Pages site is built from the
gh-pages
branch. - Click “Visit site” at the top of the page. Whenever you edit this site in RStudio, you can use the three Git commands to publish it automatically. It’ll take a couple minutes for the site to change.
11 Credit
I learned this from a video by Melissa Van Bussel. My tutorial differs from hers in that I use RStudio’s terminal instead of a Windows terminal with zsh.
I frequently forget the things I’ve learned, and it’s annoying having to dig through paper notebooks. Obsidian, Notion, and other software are additionally annoying because I keep overfixating on settings.
You know what isn’t so terrible? RStudio (it helps that I’ve been acquainted with it since 2018). It’s nice having your own website to reference while also doubling as your portfolio. So, if you’re like me, create your own website!