This website is built with Gatsby, a static site generator with Markdown-based websites and a rich ecosystem of plugins.
$ tree -L 1
.
├── assets # Website assets: favicon, logo, etc.
├── CHANGELOG.md
├── content # Markdown/webpage 'home'
├── gatsby-config.js # Sitewide configuration file
├── INSTALLATION.md
├── package.json # Website dependencies: uses Yarn to install
├── README.md
├── src # Theme & custom components source files
├── static # static files: PDFs, BibTeX, etc.
└── yarn.lock # Locks dependencies to specific version
Instructions sourced from the Gatsby documentation.
# Upgrade apt
$ sudo apt update
$ sudo apt -y upgrade
$ sudo apt-get install -y curl git
# Install NVM
$ curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.1/install.sh | bash
$ nvm install 14
$ nvm use 14
# Check versions
$ nvm --version
$ node --version
$ npm --version
$ npm install -g gatsby-cli
$ gatsby --version
$ gatsby --help
Gatsby has a development mode which allows for live previewing and change monitoring. To run,
$ gatsby develop
The console will show output similar to:
You can now view gatsby-starter-flex in the
browser.
⠀
http://localhost:8000/
⠀
View GraphiQL, an in-browser IDE, to explore your
site's data and schema
⠀
http://localhost:8000/___graphql
Navigate to http://localhost:8000/ to view the website.
To build the production version, run:
$ gatsby build
Note that content may not render correctly when viewing these built files locally. This is due to how relative/absolute URLs are generated by Gatsby - viewing them on an actual web server is the best way to verify content, outside of gatsby develop
.
The configured GitHub Action should automatically deploy changes to the gh-pages
branch.
Visual Studio Code has a plugin called Live Preview which simplifies web development. After installing the plugin, open the packages pane (on Mac: ⌘ + shift + P
) and launch Live Preview: Start Server
.
Existing pages can be found under ./content/pages/
, and take the form page-name/index.mdx
. MDX is an extension of Markdown with support for React.js components.
For more information, see:
Running | Dev Notes | Components | Help
To test locally, run:
yarn install
to install any dependencies, and
gatsby develop
to launch the server.
A localhost server will be started with live updates as pages and components change.
The server must be restarted if gatsby-config.js
changes.
If dependencies change, yarn.lock
and package.json
must have their updates pushed to the repo as well.
To test how CI will behave, run
rm -rf node_modules/ && yarn install && yarn deploy
Before deploying to a web hosting service, the pathPrefix
variable needs to be
updated relative to the deployed websites location.
I.e., for https://amanzi.github.io/landing-page-test
, the pathPrefix
will be landing-page-test
.
For https://amanzi.github.io/
, pathPrefix
will be /
.
This variable is located in gatsby-config.js
.
Every Markdown file under content/pages
will be compiled into a web page.
See other pages in that directory to get an idea of how these pages should be formatted.
An example page might be:
---
title: Example Markdown Page
excerpt: ok
---
<Section
heading="Example Markdown Page"
lead="Tristique ipsum tempor eget"
>
<Div style={{
maxWidth: ["none", "none", "60%"]
}}>
# Markdown Stuff
### Here, I can add Markdown components.
One should add images like this to take advantage of Gatsby features:
<Image src="placeholder.jpg" style={{mt: [4,8]}}/>
Though the regular syntax of `![alt](url)` will still work.
### Another Subsection
Remember to close the Div and Section blocks when you're done.
We have these to ensure consistent formatting (i.e., centering, body div width).
</Div>
</Section>
- Custom components are found under
src/*.js
, and the gallery component is found undersrc/components/gallery.js
.- These components can be changed at will.
- The theme components can be overridden: e.g., the footer
-
This page is built off the Flex theme:
- Theme source: https://github.com/arshad/gatsby-themes/tree/master/themes/gatsby-theme-flex
- Sample page (rendered): https://flex.arshad.io
- Sample page (source): https://github.com/arshad/gatsby-example-flex
-
Uses Theme UI for color and component management
- Documentation: https://theme-ui.com
- Edit the
src/gatsby-theme-flex/theme.js
file to change/update theming
- All assets (videos, BibTex files, etc) should go under
static
- All images should go under
assets/images
, except those being used in a photo gallery. - Photo gallery images go under
static/photo-gallery
. - Photo gallery images will also need a thumbnail image to improve loading times.
- Thumbnails can easily be created with the
mogrify
command:mogrify -resize 300 *.png
- Installed using
brew install imagemagick
- Thumbnails can easily be created with the
Videos and video thumbnails are found under static/video-gallery
.
-
Videos must be in MP4 format
- FFMPEG can be used for conversion:
ffmpeg -i ${INPUT} -vcodec h264 -acodec mp2 -b:a 32k -vf "scale=trunc(iw/2)*2:trunc(ih/2)*2" ${EXPORT}
- FFMPEG can be used for conversion:
-
Videos require a thumbnail image as well
- This is displayed when the video hasn't started loading yet
- FFMPEG can also create thumbnail images:
- This command can be used to easily create thumbnails:
ffmpeg -i ${INPUT_VIDEO} -vf "thumbnail" -frames:v 1 ${OUT_IMAGE}
- This command can be used to easily create thumbnails:
In general, this should be pretty straightforward to add new pages and edit content.
However, Gatsby.js and React.js have some small "gotchas" for those not familiar with them. Please open an issue or email me if you're having difficulties. 99 times of 100, the solution will be straightforward yet hidden from those without intimate knowledge of React.