My Static Org Blog

Welcome to my blog

2021/06/12

org-modeでブログを書く

org-static-blog

マークダウンでブログを書く際には、たとえばJekyllHugoといったStatic Site Generatorが有名だが、org-modeで同様の使い方ができないか調べてみた。 org文書からHTMLを吐き出す機能はorg-modeに組み込まれているものの、ブログのような用途は想定されておらずそのまま使うのは現実的ではない。 https://orgmode.org/worg/org-blog-wiki.html にorg-modeでブログを書くための拡張がリスティングされているので、この中で一番使い勝手がよさそうに感じたorg-static-blogで構築してみる。

インストール & 設定

init.el に以下のように設定した。

(use-package org-static-blog
  :hook
  (org-mode . org-static-blog-mode)
  :custom
  (org-static-blog-publish-title     "nukosuke's blog")
  (org-static-blog-publish-url       "https://nukosuke.github.io/blog/")
  (org-static-blog-publish-directory "~/blog/dist/")
  (org-static-blog-posts-directory   "~/blog/posts/")
  (org-static-blog-drafts-directory  "~/blog/drafts/")
  (org-static-blog-enable-tags       t)
  (org-export-with-toc               nil)
  (org-export-with-section-numbers   nil))

GitHub Pagesへのデプロイ

# .github/workflows/publish.yml
name: Publish

on:
  push:
    branches: [ main ]
  pull_request:
    branches: [ main ]

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - uses: purcell/setup-emacs@master
	with:
	  version: 27.1
      - uses: actions/checkout@v2
      - name: Retrieve org-static-blog.el
	run: curl -O https://raw.githubusercontent.com/bastibe/org-static-blog/1.5.0/org-static-blog.el
      - name: Build
	run: emacs -Q --batch -l org-static-blog.el -l config.el -f org-static-blog-publish
      - name: Deploy
	if: github.ref == 'refs/heads/main'
	uses: peaceiris/actions-gh-pages@v3
	with:
	  github_token: ${{ secrets.GITHUB_TOKEN }}
	  publish_dir: ./dist
タグ: emacs blog org-mode
他の投稿
Other posts
Creative Commons License