Basic usage of Octopress.

Install

rbenv

sudo apt install rbenv
git clone https://github.com/rbenv/ruby-build.git "$(rbenv root)"/plugins/ruby-build
rbenv install 2.7.1
rbenv versions
rbenv local 2.7.1
rbenv local --unset

rvm

rvm list
rvm install 2.7 --with-openssl-dir=$(brew --prefix openssl@1.1)/lib
rvm use 2.7

Gemfile

source "https://gems.ruby-china.com"

gem "jekyll", "~> 3.8.4"
gem 'octopress', '~> 3.0.0'
gem "minima", "~> 2.0"

group :jekyll_plugins do
  gem "jekyll-feed", "~> 0.6"
end

gem 'rdiscount', '~> 2.0'
gem 'sinatra', '~> 1.4.2'
gem "tzinfo-data", platforms: [:mingw, :mswin, :x64_mingw, :jruby]
gem "wdm", "~> 0.1.0" if Gem.win_platform?

Bundler

https://bundler.io/guides/getting_started.html

bundle install
bundle clean --force

bundle update --bundler

Usage

new post

bundle exec octopress new post hello -D Ruby

build

Here we set JEKYLL_ENV=production to enable google_analytics and disqus.

export JEKYLL_ENV=production
bundle exec jekyll serve

deploy

bundle exec jekyll build
bundle exec octopress deploy

_config.yml(default) 中配置了 jekyll build 时将静态文件生成到哪里:

source              : .
destination         : ./_site

_deploy.yml 中配置了 octopress deploy 时将存放在哪里的静态文件发布到哪里:

site_dir: _site                           # Location of your static site files.

# Note on git_branch:
# If using GitHub project pages, set the branch to 'gh-pages'.
# For GitHub user/organization pages or Heroku, set the branch to 'master'.
#
git_branch: master                        # Git branch where static site files are commited

GitHub Pages Settings 里配置了 GitHub 用于网页渲染的静态文件来源:

Your GitHub Pages site is currently being built from the master branch. Learn more.

source

源码和网站是在同一个 repo 的不同 branch 底下的。

git add .
git commit -m "$(date)"
git push origin source

Theme

https://jekyllrb.com/docs/themes/

https://github.com/jekyll/minima

layouts

ls $(bundle show minima)/_layouts
ls $(bundle show minima)/_includes

header

vi $(bundle show minima)/_includes/header.html

footer

vi $(bundle show minima)/_includes/footer.html

Extension

disqus

disqus:
  shortname: my_disqus_shortname

google_analytics

google_analytics: UA-NNNNNNNN-N

Config

_config.yml

title:  Secret Base
author: Zhengyang Song
email: songzy.thu@gmail.com
description: >- # this means to ignore newlines until "baseurl:"
  All those little bugs I have ever met.
baseurl: "" # the subpath of your site, e.g. /blog
url: "http://songzy12.github.io" # the base hostname & protocol for your site, e.g. http://example.com
github_username:  songzy12

# Default extension for new posts and pages
post_ext: md
page_ext: html

# Default templates for posts and pages
# Found in _templates/
post_layout: post
page_layout: page

# Format titles with titlecase?
titlecase: true

# Change default template file (in _templates/)
post_template: post
page_template: page
draft_template: draft

# Build settings
markdown: rdiscount
rdiscount:
  extensions:
    - autolink
    - footnotes
    - smart
theme: minima
plugins:
  - jekyll-feed

header_pages:
  - about.md

show_excerpts: true

google_analytics: UA-147981013-1

disqus:
  shortname: songzy12-github-io