Editing The Website

Editing The Website

This page serves as a step-by-step guide to introduce you to editing the website.

It will teach you the basics of Visual Studio Code, git, and GitHub required for working on the website.

⚠️
Ensure you have followed the steps here before continuing.

Open Visual Studio Code

Once open it should look something like this:

vscode-welcome

Your VSCode may look different compared to the one imaged. No worries, it is the same application.

Set your git credentials

Git needs to know who you are. Git tracks who makes what changes, so before you can actually make any, you have to tell it who you are.

To do this:

  1. Press ` or ` or click View > Terminal to open the terminal.
  2. In the terminal window you need to execute the following 2 commands:
    1. git config --global user.name "Your Name"
    2. git config --global user.email "youremail@example.com"
    • To do so, copy and paste each command into the terminal, make sure to change Your Name and yourname@example.com to your actual name and email.
    • You will have to move the cursor with the keyboard! Press enter to execute the command.

git

If you did everything correctly you should see no errors, like the image.

Clone (download) the project from GitHub

Git is a tool which tracks changes to files, it also tracks who makes those changes. GitHub is a website which holds the information git logs, along with the files it is tracking in a remote "repository", so multiple people can access it and change files at the same time independently. Cloneing is the process of downloading this repository to your computer so you can make changes yourself.

To do this:

  1. Press P or P or click View > Command Palette to open the Command Palette and search for git: Clone, once it is selected, press enter.

vscode-clone

  1. Next it will ask you for the url of the repository you want to clone, copy and paste the following https://github.com/tigerbotics7125/website, then press enter.

vscode-clone-url

  1. Next it will ask you where to put the project folder, pick a location, then select Select as Repository Destination.

vscode-clone-location

  1. Finally, it will ask you if you would like to open the folder, go ahead and select Open.

vscode-clone-open

  1. If everything has gone correct, vscode should reopen, and all the project files should appear in your file explorer.

vscode-clone-finish

Make a branch to edit your files on.

When making changes to a repository, you "commit" them to it, allowing git to keep track of who changes what.

By default, this all occurs on the main branch. In our case the main branch is what is published to the website, so we cannot simply commit every change to main, changing the website without reviewing our code first.

In order to allow for editing the website without permanently changing what is public, we can use a different branch to preview our changes before making them (mostly) permanent.

So what we are going to do is "branch" our changes from main, and once we are happy with them we will merge them back into the main branch making them public.

  1. Open the source control tab in the sidebar

source-control

  1. Click on the 3 dots, then Branch > Create Branch...

create-branch

  1. Then pick a name for your branch, ideally you should make a new branch for each page or topic you write on. Be sure to name the branch something descriptive towards your changes. After you choose a name, press enter.

name-branch

  1. After you've done this, you should be able to see your current branch in the bottom left.
You can also create and change between multiple branches from either the source control tab or by clicking on the current branch in the bottom left.

current-branch

Make your changes

At this point, you can make changes, add pages, do whatever you want.

Previewing your changes locally

If you have administrative privileges on your computer, you can run the website on your computer, this will let you test it before you commit any changes.

If you do not have administrative privileges, thats ok, it's just a little inconvenient to see your changes. Go on to the next step to see what to do.

In order to preview your changes locally:

  1. Open the terminal with ` or ` or by clicking View > Terminal.
  2. Run the command pnpm i in the terminal.
    • This will install all the dependencies the project needs.
  3. Run the command pnpm run dev in the terminal
    • This will start the web server, you should see something like the following in your terminal

terminal-server

  1. Access the website at http://localhost:3000/ (opens in a new tab) in your browser.
    • The website will compile each page as it is required, so it may take a while to go to new pages, you should be able to see what the website is doing in the terminal.
    • When you change a file, and save it, the website should automatically refresh (after it compiles again).

Committing your changes

Once you are happy with your changes, you'll want to commit them to your branch.

To do this:

  1. Open the Source Control tab again.

source-control

You'll see a list of files which have been added, modified or deleted. When you hover over a file you can "stage" it by pressing the + button, or you can stage all files by clicking the + beside "changes".

  1. Stage the changes you wish to commit to your branch.
  2. Add a commit message in the box above, something descriptive about your changes, such as "added x doc". After you do that, press the blue commit button.

stage-changes

Once you have committed your changes, you need to push your changes (send it to github)

  1. Push your changes by clicking on the three dots, then Push.
    • If it prompts you to publish the branch, that just means github doesn't doesn't know of your branch yet, go ahead and publish it.

push publish

After you push your code you should be able to see it on GitHub here (opens in a new tab). You can click the dropdown beside main to see all published branches. Your committed changes are available under your branch which you just published.

branches

Creating a pull request & previewing your changes

We are finally nearing the end, where we can get your changes pulled onto the main branch (and published to the website).

  1. Navigate to the pull request tab on the repository on GitHub or you can click this link (opens in a new tab).

pull-request

  1. Click on the New pull request button, this will open a page which compares your changes, leave the base as main, but change compare to the branch you want to pull into main. This should pull up all of the changes you did on your branch.

pr-compare

  1. Click on the Create pull request button, this will prompt you for a title and description, fill these in reasonably, once you have done that, click Create pull request.

pr-create

  1. After a minute or two, the vercel bot will comment on your pull request with a link to where you can preview your changes.

pr-preview

  1. If you decided you need to make more changes, and or you aren't actually ready for the pull request to be pulled into main, you should mark it as a draft, which you can do below the reviewers section.

pr-draft

  1. If you commit more changes to your branch (and push them), they will automatically be added to the pull request, where the vercel bot will build the website again, and you can preview your changes. This is your alternative if you cannot test the website locally on your computer.

pr-more-commits

Merging your pull request

In order to merge your pull request onto main (and get published on the website) it must pass the following checks.

  1. A review from an admin (either Jeff or Stover)
  2. The vercel build to not fail (why would we publish a broken website?)
  3. Any comments from the vercel preview to be resolved. (ensuring there is no debate on the page before it is published)