Local Setup - Team3128/team3128.github.io GitHub Wiki
This guide explains how to set up your local computer for developing and deploying changes to our website.
Prerequisites
In order to edit the website, you need a GitHub account and to be a part of our team's GitHub organization. You can create an account at github.com, and talk to the current Head of Controls to add you to the organization.
This guide will likely take anywhere from 0.5 to 2.0 hours, depending on the speed of your computer and your experience level with computers.
Necessary Applications
In order to develop/deploy locally, you need two applications.
- GitHub Desktop. As you've probably seen by now, our website is hosted by GitHub. GitHub is an online service that hosts
git
repositories.git
is a version control system, which lets programmers collaborate on and track the history of projects. For the purposes of the website, GitHub will serve as a place to upload the HTML/CSS/JS files that builds up our website (like Google Drive, but fancier). - Visual Studio Code. Visual Studio Code is an open-source IDE developed by Microsoft. It is incredibly fast and lightweight, and it's essentially a glorified text editor. It's the IDE we use for all of the robot code development on the team, but it makes organizing/editing files and photos incredibly easy.
Installing GitHub Desktop
First, we'll install GitHub desktop.
- Go to desktop.github.com
- Click the purple
Download for macOS
orDownload for Windows
button (depends on your OS) - Follow the instructions for installing GitHub Desktop
- Open the GitHub Desktop app and follow the setup steps
Installing Visual Studio Code
Next, we'll install Visual Studio Code
- Go to code.visualstudio.com
- Click the green
Download for Mac
orDownload for Windows
button (depends on your OS) - Follow the instructions for
Installation
in the setup guide for macOS or Windows - Ensure that you can open the Visual Studio Code app
Cloning and Editing the Website
Cloning the team3128.github.io repository
Now that you have both GitHub Desktop and VS Code installed, you can "clone" the repository for our website to your computer. This means that all of the files for the website will be downloaded; with GitHub desktop, you can download any changes that have been made elsewhere (this is known as a git "pull") and upload changes you've made (this is known as a git "push").
- Open GitHub Desktop
- Click the
Clone Repository
button. (If you can't see it, open theFile
menu and clickClone Repository...
) - In the tab bar at the top of the
Clone a Repository
popup, clickGitHub.com
- in the
Filter...
text field, typeteam3128.github.io
- At the bottom of the window, in the
Local Path
section, clickChoose...
- Navigate to and select the directory in which you want the website files to be stored on your computer
- Click
Clone...
Editing the website in Visual Studio Code
Now that you've cloned our team's website, you can edit it in Visual Studio Code. While you can edit the files of the website in any text editor, I'd recommend that you follow the steps to open it in Visual Studio Code.
- Open VS Code
- In the application menu, click
File > Open...
- Navigate to where you cloned the
team3128.github.io
repository, and open that folder
You can navigate the files and folders in the website's repository using the sidebar on the left. To learn which files and folders do what, and which specific files to edit to accomplish whatever goals, check out the Website Structure page.
Downloading/Uploading Changes
Now that you've downloaded the website and can edit it on your computer, there are two more important things to worry about: downloading changes whenever other people (or you, from another computer) makes them, and uploading the changes that you make.
Downloading changes
In order to download changes, all you need to do is click the rightmost button on the toolbar of GitHub Desktop. The button will either read Fetch origin
or Pull origin
(when there are changes that GitHub Desktop has detected).
IMPORTANT: Before you start working on the website, make sure to pull changes so your edits do no conflict with those others have made. If you do end up with this problem, you'll have to manually fix merge conflicts (if this happens, and you don't know what to do, ask someone from Controls).
Uploading your changes
Uploading your changes is a two-step process.
Commit. git
is a version control system, meaning that when you save a file, they don't automatically go anywhere. In order to make the changes semi-permanent, you need to "commit" the files, or tell git
that you'd like to save the current state of your project. In order to commit,
- Navigate to the
team3128.github.io
repository in GitHub Desktop - On the tab bar under the
Current Repository
dropdown, click the left tab labelledChanges
- Near the bottom of the left sidebar, in the
Summary (required)
field, type a short description of the changes you made - At the bottom of the left sidebar, click the blue
Commit to master
button
Push. Once you've made your changes locally, you need to upload them to GitHub. Do this by clicking the rightmost button on the upper toolbar, which will now say Push origin
.
Previewing the Website Locally
The best part about all of this is that you can edit files and automatically generate the website (with all of those changes applied) on your computer before you push the changes to GitHub. To do this, we're going to need to install Jekyll, which is the magic code library that converts all of our website files into an actual website.
This process is a little involved (and requires administrator access), so make sure you have some time (and maybe some water and a snack).
Installation
macOS
- Install Xcode. You also have to open it once to accept the License Agreement.
- Open Terminal (
Applications/Utilities/Terminal.app
) - Run
xcode-select --install
. This installs command-line tools so you can do fun Terminal hackery. - Run
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
. This installs Homebrew, a package manager for macOS. It actually does a lot of cool things, so if you're interested in software development (working withopenCV
,python
,heroku
, and a whole slew of UNIX/Linux things), definitely read more about it. - Run
brew install ruby
. This installs the latest version of Ruby. - Run
macOS High Sierra (10.14) and earlier:echo 'export PATH=/usr/local/opt/ruby/bin:$PATH' >> ~/.bash_profile
macOS Catalina (10.15) and later:echo 'export PATH=/usr/local/opt/ruby/bin:$PATH' >> ~/.zshrc
- Close the Terminal window
- Open a new Terminal window
- Run
gem install --user-install bundler jekyll
. This actually installs Jekyll. - Run
version=$(ruby -v); version=${version:5:3}; cmd='export PATH=$HOME/.gem/ruby/'; cmd+=$version; cmd+='.0/bin:$PATH'
- Run
macOS High Sierra (10.14) and earlier:echo $cmd >> ~/.bash_profile
macOS Catalina (10.15) and later:echo $cmd >> ~/.zshrc
- Run
gem install jekyll-redirect-from
You did it!
Windows
- Go to RubyInstaller Downloads and download the recommended version. This installs the latest version of Ruby.
- Run the downloaded installer with the default options
- At the last step of the installer, run the
ridk install
step - Open a new command prompt window from the Start menu
- Run
gem install jekyll bundler
. This actually installs Jekyll. - Run
gem install jekyll-redirect-from
You did it!
Hosting the website locally
Now that you've installed Jekyll, you can actually run the website server on your own computer. To start the server:
- Open up the website project in VS Code
- In the application menu, click
Terminal > New Terminal
- In the Terminal window at the bottom of the screen, run
jekyll serve
(if that doesn't work, trybundler jekyll serve
) - After the initial build is successful, the output have a line that looks like the following:
Server address: http://127.0.0.1:5000
orServer address: http://localhost:4000
.command+click
(macOS) orcontrol+click
(Windows) that link.
Finally, after who know how long, you're ready to go. From now on, any time you want to preview the version of the website with all of the edits you've made on your computer, just open the VS Code terminal window and execute the serve
command.
Every time you save, the website will automatically rebuild, and can be previewed at that address. However, only you will be able to see that website preview. None of your changes will actually appear on the website until you complete the steps to upload them.