Source Blogdown files for the corelab.io website
This repository contains the source files for the CORE Lab webpage (corelab.io).
The site is built in the Blogdown R Package and this repository stores the source Blogdown files. We then use a Netlify.com account, point it to this repository, and it "knits" the source files into .html and other web-compatible files that are published. The domain name ("corelab.io") is registered on namesilo.com, and you enter that information in to Netlify. If lab members can't find the necessary logins/passwords, ask the PI.
The workflow to edit the webpage is to fork the files to your GitHub account, clone the files locally, make any edits, commit and push the changes back to your GitHub account, then submit a "Pull Request" to the main co-relab/co-relab_source branch on GitHub. One of the admins on that account will need to accept those changes before they are official.
Basic steps for CORE lab members to edit the webpage:
- Ensure you have R and R Studio installed.
- Create a GitHub account.
- Fork the repository into your own account:
- If necessary, Install Git (comes with MacOS by default)
- Clone (e.g., download the files and create a Git repository on your local hard disk) the repo locally. To do this, first go to the forked repository on GitHub, click the "Clone or Download" button, copy the link.
Open a Terminal (or cmd prompt), navigate to where you want the files to be stored on your hard disk (use the 'cd' command in Terminal, which changes your directory), and run:
git clone <copied url>
<copied url> with your clipboard.
This will create a new directory on your computer: co-relab_source
- Navigate on your computer to the new co-relab_source folder and open co-relab_source.rproj in R Studio.
- Also open co-relab_source_rscript.R (the R script) in the same R window. Using R Projects eliminates the need to set a working directory each time (it's automatically set to the folder containing the .rproj file).
- In the Terminal of R Studio (or your regular command line), configure the remote repository so you can update your local files with changes from the main repo:
git remote add upstream https://github.com/co-relab/co-relab_source.git
- Each time before you start editing the page, update your local repo and resolve any conflicts. You can do this in R Studio by using the UI interface in the upper right "Git" tab, or via the R Studio 'terminal' (a tab where the Console usually is):
git fetch upstream
git checkout master
git merge upstream/master
If you get conflicts you will have to resolve them before it will let you merge. IF you want to overwrite your local changes with the main repo you can "stash" your files like this:
git stash save --keep-index
If you don't want to keep your stashed files, drop them:
git stash drop
- At this point, just follow instructions in the R script to edit the page.
- Once you're done, you'll "Commit" those changes back to your local repository using the "Git" window in R Studio: Checkbox the files you want to commit (usually all of them), then press "Commit". Write a commit message that explains what changes were made, and press "Commit" in the new window.
- Then, to "Push" these changes back to your fork on GitHub, press the "Push" button in R Studio.
- Finally, submit a "Pull Request" to send these changes back to the original repository and make them live on the webpage: go to GitHub.com, login on your account, and submit a "Pull Request". After this, a website admin (Rick or Hans, at the moment) needs to login to the 'co-relab' GitHub account, and merge the pull request.
Note: You need to be authenticated to your GitHub account on your pc or it will give you an error.
Advanced note: Sometimes the site won't deploy on Netlify and you have to debug why that is. In the past, on Netlify under 'build and deploy', 'environment', I've had to add an environment variable "HUGO_VERSION" and specify the same version I built it in (as I write this, hugo 0.58.3). However, this caused problems later when it got out of date (so I removed that environment variable, causing it to use the most recent version of Hugo).