HackDay – Create a Quarto Book
Learning Objectives
- Clone a Quarto book template
- Edit the yaml to customize the book
- Add content to your book
- Put online via GitHub Pages
Copy the template
This part is done on GitHub.
- Go to https://github.com/nmfs-opensci/NOAA-quarto-book
- Follow the instructions (carefully) in the ReadMe: https://github.com/nmfs-opensci/NOAA-quarto-book/blob/main/README.md
Clone your new GitHub repo.
This part is done on the JupyterHub or your local computer.
JupyterHub
- https://nmfs-openscapes.2i2c.cloud/
- Use defaults (image and size of machine)
- Authenticate to GitHub
- Open a terminal.
- Type
gh-scoped-creds
. - Copy the code, click link and paste in.
- Click the link that appears and give the hub permission to push to your new repo (or all repos).
- Open RStudio
- File > New Project > Version Control > Git
- Paste in
https://github.com/<your username>/<repo name>
On your local computer in RStudio
You must have already set up Git and GitHub Authentication to work with RStudio.
- Open RStudio
- File > New Project > Version Control > Git
- Paste in
https://github.com/<your username>/<repo name>
On your local computer in GitHub Desktop
- Open GitHub Desktop
- File > Clone repository
- Click the Git tab in the pop-up.
- Paste in
https://github.com/<your username>/<repo name>
- Change where the directory will be made or note where it is being made.
- Open RStudio
- File > New Project > Existing Directory
- Navigate to the directory created in step 1.
Note to push changes to GitHub you will need to either use GitHub Desktop or have set up RStudio to work with Git and GitHub.
Edit the yaml
- Open the new project for your book in RStudio.
- Open
_quarto.yml
- Edit the meta data (title, authors, urls, etc)
Swap in a new logo and favicon
- Upload your image file
- Edit the
_quarto.yml
to point to that image - Same for favicon
Render your book
In RStudio.
- Click the Build tab in the upper right panel of RStudio.
- Click “Render Book”. All formats or Html is fine.
- Book should pop up in a new window.
- It didn’t? Click on
_book
. Right click onindex.html
and select “Open in browser”
- It didn’t? Click on
What are all the pieces in the template?
- Click on Files in the lower right panel.
- The chapters are in the “content” directory
- Images are in “images” or “content/images” directory.
- Other files set up the “look”
Edit index.qmd
- Open
index.qmd
- Edit
- Render Book
Edit a chapter
- Open the content directory in right lower panel
- Rename
setup.qmd
tochapter-1.qmd
or whatever you want. - Open
_quarto.yml
and edit this part:
chapters:
- index.qmd
- content/setup.qmd
Change it to
chapters:
- index.qmd
- content/chapter-1.qmd
- Edit the content. Make sure to keep the title like it is at the top.
- Render Book.
Push your changes up to GitHub
GitHub will run an Action to make your book.
REPEAT!
Keep working on your book and Jon and I will help where you get stuck.