Static Blog Using Jekyll  

This is what it took me to migrate from WordPress to Jekyll:

  • Import blog using the wordpressdotcom importer.
  • Use Disqus WP plugin to export comments into Disqus.
  • Generate static pages (include Disqus code in Jekyll template).
  • Add search functionality.
  • Add personal pages (about/search/rss).

Done! (A preview is available here.)

Update:

  • Adding tags was a lot more effort. A little help from this gist saved the day.
  • Adding pages for year, month and day was a ton more effort. I modified archive.rb from josegonzalez and also customized his _layout/archive_*.html
  • Added an error handler with some JS to show my own custom error page.

You can find the sources here: https://github.com/scharan/scharan.github.com.

Update:

I also modified metajack’s jekyll.el to add a date: header (with date & time) on publish: https://gist.github.com/1171592. The gist:

;; jekyll.el
;;
;; Emacs support for Jekyll blogs.
;;
;; To use, just put this file somewhere in the load path and
;; (require 'jekyll)
;;
;; Here are my key bindings:
;; C-c b d - Show all drafts
;; C-c b p - Show all posts
;; C-c b n - Create new draft
;; C-c b P - Publish current draft
;;
;; (global-set-key (kbd "C-c b n") 'jekyll-draft-post)
;; (global-set-key (kbd "C-c b P") 'jekyll-publish-post)
;; (global-set-key (kbd "C-c b p") (lambda ()
;; (interactive)
;; (find-file "~/Sources/blog/_posts/")))
;; (global-set-key (kbd "C-c b d") (lambda ()
;; (interactive)
;; (find-file "~/Sources/blog/_drafts/")))
(provide 'jekyll)
(defvar jekyll-directory nil
"Path to Jekyll blog.")
(defvar jekyll-drafts-dir "_drafts/"
"Relative path to drafts directory.")
(defvar jekyll-posts-dir "_posts/"
"Relative path to posts directory.")
(defvar jekyll-post-ext ".markdown"
"File extension of Jekyll posts.")
(defvar jekyll-post-template
"---\ntitle: %s\n---\n\n"
"Default template for Jekyll posts. %s will be replace by the post title.")
(defun jekyll-make-slug (s)
"Turn a string into a slug."
(replace-regexp-in-string
" " "-" (downcase
(replace-regexp-in-string
"[^A-Za-z0-9 ]" "" s))))
(defun jekyll-yaml-escape (s)
"Escape a string for YAML."
(if (or (string-match ":" s)
(string-match "\"" s))
(concat "\"" (replace-regexp-in-string "\"" "\\\\\"" s) "\"")
s))
(defun jekyll-draft-post (title)
"Create a new Jekyll blog post."
(interactive "sPost Title: ")
(let ((draft-file (concat jekyll-directory jekyll-drafts-dir
(jekyll-make-slug title)
jekyll-post-ext)))
(if (file-exists-p draft-file)
(find-file draft-file)
(find-file draft-file)
(insert (format jekyll-post-template (jekyll-yaml-escape title))))))
(defun jekyll-publish-post ()
"Move a draft post to the posts directory, and rename it so that it
contains the date."
(interactive)
(cond
((not (equal
(file-name-directory (buffer-file-name (current-buffer)))
(concat jekyll-directory jekyll-drafts-dir)))
(message "This is not a draft post.")
(insert (file-name-directory (buffer-file-name (current-buffer))) "\n"
(concat jekyll-directory jekyll-drafts-dir)))
((buffer-modified-p)
(message "Can't publish post; buffer has modifications."))
(t
(let ((filename
(concat jekyll-directory jekyll-posts-dir
(format-time-string "%Y-%m-%d-")
(file-name-nondirectory
(buffer-file-name (current-buffer)))))
(old-point (point)))
(rename-file (buffer-file-name (current-buffer))
filename)
(kill-buffer nil)
(find-file filename)
(while (re-search-forward "\n---\n" nil t) ; Find the end of YAML header
(replace-match (concat "\ndate: " (format-time-string "%Y-%m-%d %H:%M:%S") "\n---\n")) )
(save-buffer)
(set-window-point (selected-window) old-point)))))
view raw jekyll.el hosted with ❤ by GitHub