Nikola와 emacs org 모드로 블로그하기

Nikola 설치

참조

brew install python3
pip3 install virtualenv
virtualenv nikola
cd nikola
source bin/activate
pip install --upgrade pip setuptools wheel
pip install --upgrade "Nikola[extras]"

사이트 생성

blog라는 사이트를 만든다.

nikola init --demo blog

orgmode 플러그인

org 모드로 글을 작성할 수 있게 orgmode 플러그인 설치한다.참조

nikola plugin -i orgmode

conf.py

conf.py에 orgmode에 관한 설정을 추가한다.

COMPILERS = {
    ...
    "orgmode": ('.org',)
}

...

POSTS = (
    ...
    ("posts/*.org", "posts", "post.tmpl"),
)
PAGES = (
    ...
    ("pages/*.org", "pages", "page.tmpl"),
)

gitlab 호스트에서 html 파일들을 생성하지 않고 로칼에서 생성한 public 디렉토리를 gitlab에 올리기 위해서 OUTPUT_FOLDER 를 public으로 바꾼다.

...
OUTPUT_FOLDER = 'public'
...

코드 블럭의 테마를 monokai로 한다.

CODE_COLOR_SCHEME = 'monokai'

custom.css

blog/files/assets/css/custom.css에 본인의 취향에 맞게 스타일을 수정한다.

h1, h2, h3, h4, h5, h6 {
    font-family: "Nanum Myeongjo","Playfair Display",Georgia,"Times New Roman",serif;
    margin-top: 0.5em;
}

body {
    font-family: "Noto Serif KR",-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"Helvetica Neue",Arial,"Noto Sans",sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji",serif;
    line-height: 1.2em;
}

pre {
    font-family: "Source Code Pro",SFMono-Regular,Menlo,Monaco,Consolas,"Liberation Mono","Courier New",monospace
}

.page-description {
    font-family: "Merriweather","Noto Serif KR",serif;
}

p, ol {
    margin-bottom: 1em;
}

시험 가동

잘 되는지 띄워본다.

nikola auto

브라우저에서 http://127.0.0.1:8000/ 에 접속해본다.

글 작성

새 글을 작성해 본다.

nikola new_post -f orgmode

posts 디렉토리 밑에 새 파일이 생겼을 것이다.

.gitlab-ci.yml

gitlab.io에 퍼블리슁 하기 위해서 .gitlab-ci.yml을 작성한다.

image: alpine:latest

pages:
  stage: deploy
  script:
  - echo 'Nothing to do...'
  artifacts:
    paths:
    - public
  only:
  - master

gitlab

https://gitlab.com 에 계정(appledelhi)과 프로젝트(appledelhi.gitlab.io)를 만들고 ssh-key를 등록한다.

git

blog 디렉토리에 git repository를 만든다.

git init .
git remote add origin git@gitlab.com:appledelhi/appledelhi.gitlab.io.git

.gitignore

/.doit.db
/README.txt
/__pycache__
/cache

퍼블리쉬

git commit 하고 git push한다. https://appledelhi.gitlab.io/ 에 잘 퍼블리쉬 되었는지 가본다.

git commit -a -m "Initial Commit"
git push

댓글

Comments powered by Disqus