6  Create and host a website

6.1 Creating a website with Quarto

This tutorial guides you through creating a simple, yet professional-looking website using Quarto.

Step W1: Install Quarto

Ensure Quarto is installed on your system. If not, download and install it from Quarto’s official website.

Step W2: Create a website

Follow the tutorial that you find here.

Step W3: Copy the _site directory

After you have rendered your website a directory “_site” appears in the project folder that contains your website. Copy all files of that directory to a directory where you want to save your website. Let’s say my_website.

In the terminal you can do this with

mkdir /home/sthu/my_website/
cp -r /home/sthu/quarto_website/_site/* /home/sthu/my_website/

6.2 Hosting the website on GitHub

R Studio and Quarto offers you various ways to publish the website. I explain you a way that worked out well for me.

Step G1: Create a GitHub account

GitHub will host your thesis website and manage version control for your thesis project. If you don’t already have a GitHub account, you’ll need to create one: Sign up at GitHub.

Step G2: Create a repository

Create a repository. Name the repo with your username followed by github.io. You find a tutorial here.

Step G3: Obtain a personal access token

A personal access token (PAT) is required to authenticate with GitHub from Quarto and RStudio. This token allows you to push changes to your repository securely. Follow the instructions to create a personal access token on GitHub. Alternatively, you can do the following in R:

if (!require(pacman)) install.packages("pacman")
pacman::p_load(usethis)
create_github_token() 

Make sure to note down your token and keep it secure. You’ll use this token in RStudio and Quarto to authenticate your GitHub operations.

Step G4: Install and Learn Git

See Section 4.2.

Step G5: Upload the website to GitHub

Use the Terminal of R Studio. Go to the directory with your website that you have copied in Step W3. Then initiate a git repository on the command line, connect it to the repository created in Steph G2 on GitHub and finally push it:

cd /home/sthu/my_website/
echo "# test" >> README.md
git init
git add README.md
git commit -m "first commit"
git branch -M main
git remote add origin https://github.com/test-hsf/test.git
git push -u origin main

Alternatively, you can clone a repository, make some changes, and then push those changes back to GitHub. Here are the Bash commands to accomplish this:

# Clone the repository
git clone https://github.com/your-username/your-repository.git

# Make changes, here adding a new file as an example
echo "Some content for the new file" > newfile.txt

# Add the new file to the repository
git add newfile.txt

# Commit the changes
git commit -m "Add new file"

# Push the changes back to GitHub
git push origin main