BLOG / 블로그 관리 / 26 March 2023 / by LeeDiculous

Github Pages 미지원 Plugin 빌드 배포

jekyll 테마를 구매하고 성공적으로 Github page에서 실행했습니다. 그러나 페이지가 정상적으로 동작하는지 확인하던 중에, Archives 페이지 쪽에서 404에러가 나는 것을 확인했습니다.

로컬에서 실행 했을 시, 문제 없이 동작하는 것을 확인하고 이를 단서로 원인를 찾아보았습니다. 원인은 현 jekyll 테마에 적용되어 있는 jekyll-archives 플러그인이 Github Page에서 지원하지 않기에 정상 동작하지 않는 것이였습니다.

우선 테마가 있는 경로에 rakefile이라는 파일명으로 파일을 생성합니다.

require "rubygems"
require "tmpdir"

require "bundler/setup"
require "jekyll"

desc "Generate blog files"
task :generate do
  Jekyll::Site.new(Jekyll.configuration({
    "source"      => ".",
    "destination" => "_site"
  })).process
end

desc "Generate and publish blog to gh-pages"
task :publish => [:generate] do
  Dir.mktmpdir do |tmp|
    cp_r "_site/.", tmp

    pwd = Dir.pwd
    Dir.chdir tmp

    system "cd .."
    system "git init"
    system "git add ."
    #system "git config --global user.email you@example.com"
    #system "git config --global user.name Your Name"
    message = "Site updated at #{Time.now.utc}"
    system "git commit -m #{message.inspect}"
    system "git remote add origin git@github.com:LeeDiculous/LeeDiculous.github.io.git"
    system "git push origin main --force"

    Dir.chdir pwd
  end
end

위 내용을 rakefile에 작성한 후, 터미널에 rake publish 명령어를 입력하면 정상적으로 배포되어 jekyll-archives 플러그인을 사용할 수 있게 됩니다.

Tags:
Comments