Github Page 1.Basic

8 minute read

Creating Github Pages Site with Jekyll

Jekyll 설치

Git 설치

bundler 설치

  • Ruby gem 종속성을 관리
  • Jekyll 빌드 에러를 줄이고
  • 환경 관련 버그를 방지한다

사이트 생성

  1. Git bash 연다
  2. 저장소의 로컬 복사본이 없다면, 소스 파일 저장하려는 경로로 부모 폴더로 이동
$ cd <PARENT-FOLDER>
  1. 로컬 깃 저장소를 초기화
$ git init <REPOSITORY-NAME>
### 초기화 안 한 경우
> Initialized empty Git repository in /Users/octocat/my-site/.git/
# Creates a new folder on your computer, initialized as a Git repository

### 이미 초기화 한 경우
Reinitialized existing Git repository in /mnt/c/Users/daybreak/vscode_projects/aimpugn.github.io/.git/
  1. 저장소 디렉토리(작업 디렉토리)로 이동
$ cd <REPOSITORY-NAME>
# Changes the working directory
  1. 어떤 퍼블리싱 소스를 사용할 것인지 결정

The publishing source for your GitHub Pages site is the branch and folder where the source files for your site are stored.

  1. 사이트의 퍼블리싱 소스로 이동. 가령 기본 브랜치에서 docs에서 사이트를 퍼블리싱할 경우:
$ mkdir docs
# Creates a new folder called docs
$ cd docs

gh-pages로 사이트 퍼블리싱할 경우, gh-pages 브랜치 생성 및 체크아웃

$ git checkout --orphan gh-pages
# Creates a new branch, with no history or contents, called gh-pages and switches to the gh-pages branch
# 결과
# M       .gitignore
# M       _config.yml
# M       _posts/containerd/2020-11-23-cotainerd-BUILDING.md
# M       _posts/couchbase/2020-10-26-Couchbase-N1QL-Reference-Statements-SELECT.md
# M       "_posts/couchbase/2020-10-26-Couchbase-\354\232\251\354\226\264.md"
# M       _posts/couchbase/2020-11-05-Couchbase-N1QL_tutorial.md
# M       _posts/couchbase/2020-11-05-Couchbase-PHP_SDK-Getting_Started.md
# M       _posts/couchbase/2020-11-05-Couchbase-PHP_SDK-Working_with_Data.md
# M       _posts/couchbase/2020-11-06-Couchbase-Learn-Data_Model.md
# M       _posts/couchbase/2020-11-06-Couchbase-N1QL_Operators.md
# M       _posts/golang/2020-11-23-golang-cmd-go.md
# M       _posts/makefile/2020-11-23-Makefile_Basic.md
# M       _posts/markdown/2020-11-29-Markdown-syntax.md
# M       _posts/network/2020-11-29-Network-firewall-cmd-masquerade.md
# M       "_posts/strategies_to_solve_problems/2020-10-14-3.6-\354\213\244\354\210\230-\354\227\260\354\202\260\354\235\230-\354\226\264\353\240\244\354\233\200.md"
# M       _posts/troubleshooting/2020-10-27-troubleshooting-php.md
# M       _posts/troubleshooting/2020-11-29-troubleshooting-Docker-Network.md
# M       index.md
# Switched to a new branch 'gh-pages'
# 그리고 기존 파일들은 새로운 커밋 대상이 된다
  1. 새로운 jekyll 사이트 생성하려면, jekyll new 명령어 사용

Bundler 설치한 경우. [](https://pages.github.com/versions/)은 링크 참고.

$ bundle exec jekyll <DEPENDENCY-VERSION> new .
# Creates a Jekyll site in the current directory
# 하지만 버전을 명시하니 에러가 나서 그냥 버전 없이 실행
# jekyll -v // jekyll 4.1.1
# fatal: 'jekyll 3.9.0' could not be found. You may need to install the jekyll-3.9.0 gem or a related gem to be able to use this subcommand.
bundle exec jekyll new .
Running bundle install in <PARENT-FOLDER>/aimpugn.github.io/docs...
  Bundler: /home/aimpugn/gems/gems/bundler-2.1.4/lib/bundler/resolver.rb:290:in `block in verify_gemfile_dependencies_are_found!': Could not find gem 'minima (~> 2.5)' in any of the gem sources listed in your Gemfile. (Bundler::GemNotFound)
  Bundler: from /home/aimpugn/gems/gems/bundler-2.1.4/lib/bundler/resolver.rb:258:in `each'
  Bundler: from /home/aimpugn/gems/gems/bundler-2.1.4/lib/bundler/resolver.rb:258:in `verify_gemfile_dependencies_are_found!'
  Bundler: from /home/aimpugn/gems/gems/bundler-2.1.4/lib/bundler/resolver.rb:49:in `start'
  Bundler: from /home/aimpugn/gems/gems/bundler-2.1.4/lib/bundler/resolver.rb:22:in `resolve'
  Bundler: from /home/aimpugn/gems/gems/bundler-2.1.4/lib/bundler/definition.rb:258:in `resolve'
  Bundler: from /home/aimpugn/gems/gems/bundler-2.1.4/lib/bundler/definition.rb:170:in `specs'
  Bundler: from /home/aimpugn/gems/gems/bundler-2.1.4/lib/bundler/definition.rb:237:in `specs_for'
  Bundler: from /home/aimpugn/gems/gems/bundler-2.1.4/lib/bundler/definition.rb:226:in `requested_specs'
  Bundler: from /home/aimpugn/gems/gems/bundler-2.1.4/lib/bundler/runtime.rb:101:in `block in definition_method'
  Bundler: from /home/aimpugn/gems/gems/bundler-2.1.4/lib/bundler/runtime.rb:20:in `setup'
  Bundler: from /home/aimpugn/gems/gems/bundler-2.1.4/lib/bundler.rb:149:in `setup'
  Bundler: from /home/aimpugn/gems/gems/bundler-2.1.4/lib/bundler/setup.rb:20:in `block in <top (required)>'
  Bundler: from /home/aimpugn/gems/gems/bundler-2.1.4/lib/bundler/ui/shell.rb:136:in `with_level'
  Bundler: from /home/aimpugn/gems/gems/bundler-2.1.4/lib/bundler/ui/shell.rb:88:in `silence'
  Bundler: from /home/aimpugn/gems/gems/bundler-2.1.4/lib/bundler/setup.rb:20:in `<top (required)>'
  Bundler: from /usr/lib/ruby/2.7.0/rubygems/core_ext/kernel_require.rb:92:in `require'
  Bundler: from /usr/lib/ruby/2.7.0/rubygems/core_ext/kernel_require.rb:92:in `require

실행 결과 디렉토리 구조:

.
├── _config.yml
├── docs
   ├── 404.html
   ├── Gemfile
   ├── _config.yml
   ├── _posts
      ├── GNUBinaryUtilities
      ├── containerd
         └── 2020-11-23-cotainerd-BUILDING.md
      ├── couchbase
         ├── 2020-10-26-Couchbase-N1QL-Reference-Statements-SELECT.md
         ├── 2020-10-26-Couchbase-용어.md
         ├── 2020-11-05-Couchbase-N1QL_tutorial.md
         ├── 2020-11-05-Couchbase-PHP_SDK-Getting_Started.md
         ├── 2020-11-05-Couchbase-PHP_SDK-Working_with_Data.md
         ├── 2020-11-06-Couchbase-Learn-Data_Model.md
         └── 2020-11-06-Couchbase-N1QL_Operators.md
      ├── docker
         └── 2020-11-29-Docker-0.Guides-1.Get_started.md
      ├── github_page
         └── 2020-11-30-Github-Page-1.Basic.md
      ├── golang
         └── 2020-11-23-golang-cmd-go.md
      ├── makefile
         └── 2020-11-23-Makefile_Basic.md
      ├── markdown
         └── 2020-11-29-Markdown-syntax.md
      ├── network
         └── 2020-11-29-Network-firewall-cmd-masquerade.md
      ├── shell
         └── 2020-11-23-Shell-Basic.md
      ├── strategies_to_solve_problems
         └── 2020-10-14-3.6-실수-연산의-어려움.md
      └── troubleshooting
          ├── 2020-10-27-troubleshooting-php.md
          └── 2020-11-29-troubleshooting-Docker-Network.md
   ├── about.markdown
   └── index.markdown
└── index.md

Bundler 설치 안한 경우

$ jekyll VERSION new .
# Creates a Jekyll site in the current directory
  1. Gemfile을 열고 Github Pages 사용 위한 코멘트의 안내를 따른다

# gem “jekyll”, “~> 4.1.1” # This is the default theme for new Jekyll sites. You may change this to anything you like. gem “minima”, “~> 2.5” # If you want to use GitHub Pages, remove the “gem “jekyll”” above and uncomment the line below. # To upgrade, run bundle update github-pages.

  1. gem "github-pages" 라인을 업데이트`

AS-IS: gem “github-pages”, group: :jekyll_plugins TO-BE: gem “github-pages”, “~> 209”, group: :jekyll_plugins

  1. Gemfile을 저장하고 닫느다

  2. 로컬에서 테스트할 경우 이 링크 참고

  3. 저장소를 remote로 추가

git remote add origin https://github.com/USER/REPOSITORY.git
# 이미 있다면 이미 존재한다는 에러 발생
# fatal: remote origin already exists.
  1. 저장소를 Github로 푸시
git push -u origin gh-pages

하지만 에러 발생

error: src refspec gh-pages does not match any

검색 결과 새로운 브랜치 생성 후 커밋 없이 푸시를 하려 했기 때문

git commit
[gh-pages (root-commit) d8bb5dc] Github Pages start
20 files changed, 3296 insertions(+)
 create mode 100644 .gitignore
 create mode 100644 _config.yml
 create mode 100644 _posts/containerd/2020-11-23-cotainerd-BUILDING.md
 create mode 100644 _posts/couchbase/2020-10-26-Couchbase-N1QL-Reference-Statements-SELECT.md
 create mode 100644 "_posts/couchbase/2020-10-26-Couchbase-\354\232\251\354\226\264.md"
 create mode 100644 _posts/couchbase/2020-11-05-Couchbase-N1QL_tutorial.md
 create mode 100644 _posts/couchbase/2020-11-05-Couchbase-PHP_SDK-Getting_Started.md
 create mode 100644 _posts/couchbase/2020-11-05-Couchbase-PHP_SDK-Working_with_Data.md
 create mode 100644 _posts/couchbase/2020-11-06-Couchbase-Learn-Data_Model.md
 create mode 100644 _posts/couchbase/2020-11-06-Couchbase-N1QL_Operators.md
 create mode 100644 _posts/docker/2020-11-29-Docker-0.Guides-1.Get_started.md
 create mode 100644 _posts/golang/2020-11-23-golang-cmd-go.md
 create mode 100644 _posts/makefile/2020-11-23-Makefile_Basic.md
 create mode 100644 _posts/markdown/2020-11-29-Markdown-syntax.md
 create mode 100644 _posts/network/2020-11-29-Network-firewall-cmd-masquerade.md
 create mode 100644 _posts/shell/2020-11-23-Shell-Basic.md
 create mode 100644 "_posts/strategies_to_solve_problems/2020-10-14-3.6-\354\213\244\354\210\230-\354\227\260\354\202\260\354\235\230-\354\226\264\353\240\244\354\233\200.md"
 create mode 100644 _posts/troubleshooting/2020-10-27-troubleshooting-php.md
 create mode 100644 _posts/troubleshooting/2020-11-29-troubleshooting-Docker-Network.md
 create mode 100644 index.md

git push 결과

$ git push -u origin gh-pages
Enumerating objects: 32, done.
Counting objects: 100% (32/32), done.
Delta compression using up to 8 threads
Compressing objects: 100% (30/30), done.
Writing objects: 100% (32/32), 27.96 KiB | 3.49 MiB/s, done.
Total 32 (delta 0), reused 8 (delta 0)
remote:
remote: Create a pull request for 'gh-pages' on GitHub by visiting:
remote:      https://github.com/aimpugn/aimpugn.github.io/pull/new/gh-pages
remote:
To https://github.com/aimpugn/aimpugn.github.io.git
 * [new branch]      gh-pages -> gh-pages
Branch 'gh-pages' set up to track remote branch 'gh-pages' from 'origin'.
  1. 로컬에서 테스트
$ bundle exec jekyll serve
# 에러 발생
# Could not find gem 'github-pages (~> 209)' in any of the gem sources listed in your Gemfile.
# Run `bundle install` to install missing gems.

bundle install 실행

$ bundle install

# 결과 출력
The dependency tzinfo (~> 1.2) will be unused by any of the platforms Bundler is installing for. Bundler is installing for ruby but the dependency is only for x86-mingw32, x64-mingw32, x86-mswin32, java. To add those platforms to the bundle, run `bundle lock --add-platform x86-mingw32 x64-mingw32 x86-mswin32 java`.
The dependency tzinfo-data (>= 0) will be unused by any of the platforms Bundler is installing for. Bundler is installing for ruby but the dependency is only for x86-mingw32, x64-mingw32, x86-mswin32, java. To add those platforms to the bundle, run `bundle lock --add-platform x86-mingw32 x64-mingw32 x86-mswin32 java`.
The dependency wdm (~> 0.1.1) will be unused by any of the platforms Bundler is installing for. Bundler is installing for ruby but the dependency is only for x86-mingw32, x64-mingw32, x86-mswin32. To add those platforms to the bundle, run `bundle lock --add-platform x86-mingw32 x64-mingw32 x86-mswin32`.
Fetching gem metadata from https://rubygems.org/...........
Fetching gem metadata from https://rubygems.org/.
Resolving dependencies...
Using concurrent-ruby 1.1.7
Fetching i18n 0.9.5
Installing i18n 0.9.5
Fetching minitest 5.14.2
Installing minitest 5.14.2
Fetching thread_safe 0.3.6
Installing thread_safe 0.3.6
Fetching tzinfo 1.2.8
Installing tzinfo 1.2.8
Installing thread_safe 0.3.6
Fetching tzinfo 1.2.8
Installing tzinfo 1.2.8
Fetching zeitwerk 2.4.2
Installing zeitwerk 2.4.2
Fetching activesupport 6.0.3.4
Installing activesupport 6.0.3.4
Fetching public_suffix 3.1.1
Installing public_suffix 3.1.1
Using addressable 2.7.0
Using bundler 2.1.4
Fetching coffee-script-source 1.11.1
Installing coffee-script-source 1.11.1
Fetching execjs 2.7.0
Installing execjs 2.7.0
Fetching coffee-script 2.4.1
Installing coffee-script 2.4.1
Using colorator 1.1.0
Fetching ruby-enum 0.8.0
Installing ruby-enum 0.8.0
Fetching commonmarker 0.17.13
Installing commonmarker 0.17.13 with native extensions
Fetching unf_ext 0.0.7.7
Installing unf_ext 0.0.7.7 with native extensions
Fetching unf 0.1.4
Installing unf 0.1.4
Fetching simpleidn 0.1.1
Installing simpleidn 0.1.1
Fetching dnsruby 1.61.5
Installing dnsruby 1.61.5
Using eventmachine 1.2.7
Using http_parser.rb 0.6.0
Using em-websocket 0.5.2
Using ffi 1.13.1
Using ethon 0.12.0
Fetching multipart-post 2.1.1
Installing multipart-post 2.1.1
Fetching ruby2_keywords 0.0.2
Installing ruby2_keywords 0.0.2
Fetching faraday 1.1.0
Installing faraday 1.1.0
Using forwardable-extended 2.6.0
Fetching gemoji 3.0.1
Installing gemoji 3.0.1
Fetching sawyer 0.8.2
Installing sawyer 0.8.2
Fetching octokit 4.19.0
Installing octokit 4.19.0
Using typhoeus 1.4.0
Fetching github-pages-health-check 1.16.1
Installing github-pages-health-check 1.16.1
Using rb-fsevent 0.10.4
Using rb-inotify 0.10.1
Fetching sass-listen 4.0.0
Installing sass-listen 4.0.0
Fetching sass 3.7.4
Installing sass 3.7.4
Fetching jekyll-sass-converter 1.5.2
Installing jekyll-sass-converter 1.5.2
Fetching listen 3.3.3
Installing listen 3.3.3
Using jekyll-watch 2.2.1
Using rexml 3.2.4
Using kramdown 2.3.0
Using liquid 4.0.3
Fetching mercenary 0.3.6
Installing mercenary 0.3.6
Using pathutil 0.16.2
Using rouge 3.23.0
Using safe_yaml 1.0.5
Fetching jekyll 3.9.0
Installing jekyll 3.9.0
Fetching jekyll-avatar 0.7.0
Installing jekyll-avatar 0.7.0
Fetching jekyll-coffeescript 1.1.1
Installing jekyll-coffeescript 1.1.1
Fetching jekyll-commonmark 1.3.1
Installing jekyll-commonmark 1.3.1
Fetching jekyll-commonmark-ghpages 0.1.6
Installing jekyll-commonmark-ghpages 0.1.6
Fetching jekyll-default-layout 0.1.4
Installing jekyll-default-layout 0.1.4
Fetching jekyll-feed 0.15.1
Installing jekyll-feed 0.15.1
Fetching jekyll-gist 1.5.0
Installing jekyll-gist 1.5.0
Fetching jekyll-github-metadata 2.13.0
Installing jekyll-github-metadata 2.13.0
Using mini_portile2 2.4.0
Using nokogiri 1.10.10
Fetching html-pipeline 2.14.0
Installing html-pipeline 2.14.0
Fetching jekyll-mentions 1.6.0
Installing jekyll-mentions 1.6.0
Fetching jekyll-optional-front-matter 0.3.2
Installing jekyll-optional-front-matter 0.3.2
Using jekyll-paginate 1.1.0
Fetching jekyll-readme-index 0.3.0
Installing jekyll-readme-index 0.3.0
Using jekyll-redirect-from 0.16.0
Fetching jekyll-relative-links 0.6.1
Installing jekyll-relative-links 0.6.1
Fetching rubyzip 2.3.0
Installing rubyzip 2.3.0
Fetching jekyll-remote-theme 0.4.2
Installing jekyll-remote-theme 0.4.2
Using jekyll-seo-tag 2.6.1
Fetching jekyll-sitemap 1.4.0
Installing jekyll-sitemap 1.4.0
Fetching jekyll-swiss 1.0.0
Installing jekyll-swiss 1.0.0
Fetching jekyll-theme-architect 0.1.1
Installing jekyll-theme-architect 0.1.1
Fetching jekyll-theme-cayman 0.1.1
Installing jekyll-theme-cayman 0.1.1
Fetching jekyll-theme-dinky 0.1.1
Installing jekyll-theme-dinky 0.1.1
Fetching jekyll-theme-hacker 0.1.2
Installing jekyll-theme-hacker 0.1.2
Fetching jekyll-theme-leap-day 0.1.1
Installing jekyll-theme-leap-day 0.1.1
Fetching jekyll-theme-merlot 0.1.1
Installing jekyll-theme-merlot 0.1.1
Fetching jekyll-theme-midnight 0.1.1
Installing jekyll-theme-midnight 0.1.1
Fetching jekyll-theme-minimal 0.1.1
Installing jekyll-theme-minimal 0.1.1
Fetching jekyll-theme-modernist 0.1.1
Installing jekyll-theme-modernist 0.1.1
Fetching jekyll-theme-primer 0.5.4
Installing jekyll-theme-primer 0.5.4
Fetching jekyll-theme-slate 0.1.1
Installing jekyll-theme-slate 0.1.1
Fetching jekyll-theme-tactile 0.1.1
Installing jekyll-theme-tactile 0.1.1
Fetching jekyll-theme-time-machine 0.1.1
Installing jekyll-theme-time-machine 0.1.1
Fetching jekyll-titles-from-headings 0.5.3
Installing jekyll-titles-from-headings 0.5.3
Fetching jemoji 0.12.0
Installing jemoji 0.12.0
Using kramdown-parser-gfm 1.1.0
Fetching minima 2.5.1
Installing minima 2.5.1
Using unicode-display_width 1.7.0
Using terminal-table 1.8.0
Fetching github-pages 209
Installing github-pages 209
Bundle complete! 5 Gemfile dependencies, 91 gems now installed.
Use `bundle info [gemname]` to see where a bundled gem is installed.
Post-install message from dnsruby:
Installing dnsruby...
  For issues and source code: https://github.com/alexdalitz/dnsruby
  For general discussion (please tell us how you use dnsruby): https://groups.google.com/forum/#!forum/dnsruby
Post-install message from sass:

Ruby Sass has reached end-of-life and should no longer be used.

* If you use Sass as a command-line tool, we recommend using Dart Sass, the new
  primary implementation: https://sass-lang.com/install

* If you use Sass as a plug-in for a Ruby web framework, we recommend using the
  sassc gem: https://github.com/sass/sassc-ruby#readme

* For more details, please refer to the Sass blog:
  https://sass-lang.com/blog/posts/7828841

Post-install message from html-pipeline:
-------------------------------------------------
Thank you for installing html-pipeline!
You must bundle Filter gem dependencies.
See html-pipeline README.md for more details.
https://github.com/jch/html-pipeline#dependencies
-------------------------------------------------

Updated: