hoisharka's blog Front-end Dev Engineer

emacs org-mode jekyll

지금까지 작성한 포스트는 md파일로 포스트를 작성하고 jekyll로 html변환을 하는 방식이었다. 그런데 이제 org모드에 익숙하기 때문에 org모드로 문서작성을 많이 하는데 이것을 바로 포스팅하고 싶어졌다.

찾아보니 괜찮은 방법을 알아냈다. org 파일로 작성한 포스트를 html로 바꾸고 이것을 jekyll 서버로 올리는 방식이다. org파일은 jekyll프로젝트 하위에 _org 폴더를 만들어 보관한다.

  1. org 파일은 jekyll 프로젝트 하위에 _org 디렉토리를 만들어 보관한다.
  2. org파일을 html로 만들 때 필요한 설정을 init.el에 추가하여 실행한다. _org의 파일을 퍼블리싱하여 _posts에 놓겠다는 내용인 듯하다.

    (setq org-publish-project-alist
          '(("org keyll publish"
             ;; Path to org files.
             :base-directory "~/hoisharka.github.io/_org"
             :base-extension "org"
    
             ;; Path to Jekyll Posts
             :publishing-directory "~/hoisharka.github.io/_posts/"
             :recursive t
             :publishing-function org-html-publish-to-html
             :headline-levels 4
             :html-extension "html"
             :body-only t
             )))
    
  3. org파일의 해더에 내용을 적는다.

    #+OPTIONS: toc:nil num:nil
    #+BEGIN_EXPORT html
    ---
    
    title: emacs org-mode jekyll
    layout: post
    categories: [tool]
    tags: [emacs org-mode jekyll]
    
    ---
    #+END_EXPORT
    
  4. 그 아래 내용을 적는다.
  5. C-c C-e P p 커멘드로 퍼블리싱한다.
  6. _post 디렉토리에 html파일이 추가된 것을 확인할 수 있다.
  7. 이것을 commit 및 push 하면 포스팅이 완료된다.