To set up your personal blog with Org mode for static site generation, follow this streamlined approach using Emacs' built-in org-publish system. Here's a step-by-step guide:
1. Directory Structure
Create this folder structure:
~/blog/
├── content/
│ ├── posts/ # Org files for blog posts
│ ├── index.org # Homepage
│ └── about.org # About page
├── static/
│ ├── css/
│ │ └── style.css # Custom styles
│ └── images/ # All images
└── publish.el # Publishing config
2. Basic Configuration (publish.el)
Add this to your publish.el file (load it with M-x load-file):
(require 'ox-publish)
(setq org-publish-project-alist
'(("blog-content"
:base-directory "~/blog/content/"
:base-extension "org"
:publishing-directory "~/blog/public/"
:recursive t
:publishing-function org-html-publish-to-html
:headline-levels 4
:auto-preamble nil
:auto-sitemap t
:sitemap-filename "index.org"
:sitemap-title "My Blog"
:sitemap-sort-files anti-chronologically
:html-head "<link rel='stylesheet' href='/css/style.css'>")
("blog-static"
:base-directory "~/blog/static/"
:base-extension "css\\|js\\|png\\|jpg\\|gif\\|svg"
:publishing-directory "~/blog/public/"
:recursive t
:publishing-function org-publish-attachment)
("blog" :components ("blog-content" "blog-static"))))
3. Key Customizations
- Chronological Posts: Name post files like
posts/2024-06-15-post-title.org
- Sitemap (Homepage): Auto-generated from
index.org with reverse-chronological posts
- CSS Styling:
4. Blog Post Template
Start posts with frontmatter:
#+TITLE: Your Post Title
#+DATE: 2024-06-15
#+AUTHOR: Your Name
#+TAGS: emacs, blogging
* Section 1
Content with **bold** and [[https://example.com][links]].
* Code Snippet
#+BEGIN_SRC python
print("Hello Org mode!")
#+END_SRC
5. Publishing Commands
6. Advanced Features
7. Deployment
Sync the public/ folder to your server using:
rsync -avz ~/blog/public/ user@server:/var/www/blog
- GitHub Pages (push
public/ to a gh-pages branch)
Recommended Packages
org-superstar for prettier bullets
ox-rss for RSS feeds
htmlize for syntax highlighting
Why this works: The built-in org-publish handles all core needs without external dependencies. The sitemap auto-generates your index, CSS customizations modernize the look, and the batch command enables automation.
For a complete example, see the Org-mode Website Source. Start simple, then expand with features like tags/categories later!