This repo is used to track progress for Alexander Kallaway's 100 Days of Code Challenge (https://100daysofcode.com).
It's made available to anyone that would like to fork this repo in order to also track their progress using GitHub Pages. It uses a customized version of the Leap day theme (see preview here) and allows simple customization of page titles & colors schemes.
GitHub Pages is a static site hosting service provided by GitHub that takes Markdown files, combines them with a template, and turns them to static HTML.
With GitHub Pages enabled, code logs written in Markdown are converted to html when pushed to GitHub.
GitHub Pages uses Jekyll to build the static site. Jekyll is a Ruby-based static site generator that uses Liquid as it's templating language and Markdown as it's content source. Code logs are written in Markdown.
In order to preview and test changes, Jekyll GitHub Pages should be installed locally. GitHub recommends installing Jekyll to preview your site and help troubleshoot any failed Jekyll builds.
While Jekyll relies on Ruby and Liquid for logic and templating, you don't need to know anything other than Markdown in order to create your log. Here are a couple Markdown resources.
Ruby and Bundler need to be installed before proceeding.
Open the terminal (Terminal, Git Bash, WSL, etc.).
Check whether you have Ruby 2.1.0 or higher installed:
$ruby --version
> ruby 2.X.X
If you don't have Ruby installed, install Ruby 2.1.0 or higher.
Install Bundler:
$ gem install bundler
# Installs the Bundler gem
Fork and clone the repo, then use Bundler to install the gem dependencies.
Fork the repo by clicking the Fork button in the upper right corner of the page.
Clone (or download) the repo.
$ git clone https://github.com/<username>/100-days-log.git
$ cd 100-days-log/docs/
>
Install Jekyll and other dependencies from the GitHub Pages gem with the following command.
```bash $ bundle install
Fetching gem metadata from https://rubygems.org/............ Fetching version metadata from https://rubygems.org/... Fetching dependency metadata from https://rubygems.org/.. Resolving dependencies...
You can serve the site and enable live-reload if desired. Additional command line options exist to changes things such as port, hostname, url, etc.
Serves the local Jekyll site and rebuilds anytime a source file changes.
Navigate to the docs
folder off of the root directory.
Run the Jekyll site locally.
bundle exec jekyll serve
Preview your local Jekyll site in your web browser at
Serves, builds and auto-reloads the page when whenever a source file changes.
Navigate to the docs
folder off of the root directory.
Run the Jekyll site locally.
bundle exec jekyll serve --livereload
Preview your local Jekyll site in your web browser at
Once all changes are completed and you are satisfied that everything looks fine, the site can be deployed to GitHub with a commit and push.
Add all files to staging.
git add .
Commit with a meaningful message such as "Day 1: Title of my first entry" or "r1d1: What I did today".
git commit -m "Day 1: Deploy new log"
Push changes to GitHub
git push
Once the changes are posted it takes GitHub 1-3 minutes to generate the site.
In order to view your site you'll need to go into your repository's Settings and enable GitHub Pages.
Choose Settings from repo menu.
Click the button under Source.
Choose "master branch /docs folder".
This will refresh the page and start the build process. There is no need to choose a theme since this will be picked up from the _config.yml
file.
You can navigate back down to the GitHub Pages section to view or click the link to the new site. This might take a minute or two to generate.
A grunt task is provided that will monitor a "watch folder" and create optimized versions of any image files copied to that folder. This works for both JPGs and PNGs. and will help keep file sizes small for a log that may eventually contain 100+ images.
The files will be sized at:
The small image is sized to display properly within the template's page width. The large image is used as an expanded view if a user clicks on the small image. Both are optimized for size.
Once the Grunt task is running, any image copied to source will be optimized and place in output. Here are the source and output folder paths.
Source folder | Output folder |
---|---|
/docs/src/images/ |
/docs/assets/images/ |
An image named my-file.jpg
will be created as follows.
source | small output (570w) | large output (800w) |
---|---|---|
/docs/src/images/my-file.jpg | /docs/assets/images/my-file_small.jpg | /docs/assets/images/my-file.jpg |
The images can then be linked to in the output directory from the code log.
Run once to install package dependencies.
Navigate to the docs
folder off of the root directory.
Install npm dependencies.
npm install
Run each time to enable image optimization with watch folder.
Navigate to the docs
folder off of the root directory.
Run grunt.
npx grunt
Use this format to embed a simple, non-clickable image.
![image alt text](assets/images/my-file_small.jpg)
Use this format to embed a clickable image which displays a larger version on click.
[![image alt text](assets/images/my-file_small.jpg)](assets/images/my-file.jpg)
THIS SECTION IS A WIP... and still needs to be completed.
This is a list of items that can be customized at the top of each page.
These items can be customized for the site.
docs/assets/images/icons/favicon.ico
/_config.yml
Here's how a sample set of Markdown files would be converted.
Initially all log files are placed in the /docs
folder. This will create the html files in the root of your GitHub Pages repo site.
It is possible to create a folder structure to hold additional Markdown files. These would then be converted to HTML and hosted on GitHub Pages.
Here's the mapping.
GitHub Repo source | GitHub Pages URL |
---|---|
https://github.com/<username>/100-days-log/docs/ |
https://<username>.github.io/100-days-log/ |
Here are some paths and their URL mapping.
GitHub Repo source | GitHub Pages URL |
---|---|
/docs/README.md |
https://<username>.github.io/100-days-log/index.html |
/docs/log1.md |
https://<username>.github.io/100-days-log/log1.html |
/docs/my-notes.md |
https://<username>.github.io/100-days-log/my-notes.html |
/docs/logs/page1.md |
https://<username>.github.io/100-days-log/logs/page1.html |
/docs/school-notes/cs101.md |
https://<username>.github.io/100-days-log/school-notes/cs101.html |