How to generate and maintain this site
Table of contents
Introduction
As the name suggested, this site helps me remember all the code-related knowledge that I need. Usually it is difficult to remember how to update and maintain sites like this. That is the main purpose of this entry.
The whole system consists of three parts
- Contents, which is a list of markdown files with a specific header.
- Webpage generation is done by a gatsby plugin
- gh-pages publishes the webpage using GitHub Page.
How to make the system
- Install gatsby-cli. I did
npm install -g gatsby-cli - Start a new code-note project by
gatsby new code-notes https://github.com/MrMartineau/gatsby-starter-code-notes - The project is already a git repository. Link that to a GitHub repository. I named it
code-notes. - Follow the official instruction to generate the website and publish to GitHub Page. I specifically did
- Within the repository, install gh-pages. I did
npm install gh-pages --save-dev - Added
pathPrefix: "/code-notes",(the repository name) tomodule.exportsin the filegatsby-config.js - Added
"deploy": "gatsby build --prefix-paths && gh-pages -d public"to"scripts"inpackage.json - Created a branch called
gh-pages npm run deploywill generate the website and check-in codes to thegh-pagesbranch automatically.
- Within the repository, install gh-pages. I did
- In the GitHub webpage, go to the settings of the repository to let GitHub Pages to host the project page. Choose
gh-pagesbranch and/(root)as the path. The code-notes webpage shows up in<username>.github.io/code-notes.
In a new environment (unverified with ARM64)
Do the Step 1 above, and then npm install in the repository.
How to write a new entry
- Go to the master branch of the repository
code-notes - Add a markdown file under the
notesdirectory. About the format, check an example or just copy from an existing one. npm run deployto generate and publish. It will update thegh-pagesbranch.- Version control the notes using the master branch.