Blogging With Cryogen

I recently revived my blog by building it with the static site generator Cryogen. Working primarily in Clojure these days made using Cryogen a nice fit.

Benefits

Static site generators let you create posts in your own editor using a simple markup language such as Markdown

Because Cryogen is developed in Clojure you have a software package you can edit if you'd like

All the basics are included including support for tags, rss feed files and commenting with Disqus

Setup

As stated on the Cryogen home page the creation of a new blog is simple because the authors have created a Leiningen template.

Simply enter:

$ leiningen new cryogen blog-name

Then cd into blog-name and enter lein ring server and you can view your new blog at http://localhost:3000 .

Next you can start editing and creating files in blog-name/resources/templates/md/posts . The md assumes you are going to work with Markdown files.

Posts are created with a simple naming convention which consists of the date followed by a dash delimited name. The files themselves start with a simple map with meta data for the file.

Here is a basic example.

{:title "This-Is-An-Example" :layout :post :tags [""] :toc false} ### Headline enter stuff here

I use Emacs to edit my files so I created the following function to help when I want to create a post. To use it set posts-dir before running the following new-post function.

(defun new-post () ;; prompt for post name ;; replace spaces with dashes ;; prepend today's date ;; add .md ;; open file buffer (interactive (let* ((name (read-string "Post name: " nil 'my-history)) (date (format-time-string "%Y-%m-%d"))) ;; down case name for filename (find-file (concat posts-dir "/" (downcase (format "%s-%s.md" date (replace-regexp-in-string " +" "-" name))))) ;; enter meta map ;; {:title "name" ;; :layout :post ;; :tags [""] ;; :toc true} (insert (format "{:title \"%s\"

:layout :post

:tags [\"\"]

:toc false}



" (capitalize name))) (insert "### Headline



enter stuff here

"))))

Configuration

In addition to the map at the head of each post there is a site-wide configuration file, config.edn inside of resources/templates . Here you'll want to change the obvious values that are specific to your site. See the site-title , author , description and site-url for your first edits.

I added Disqus comments to my site and you can specify that with the two disqus settings.

Also, notice the theme setting. I'll explain that next.

Themes

To be honest I wish I found more themes for Cryogen. It comes with a few and without having much luck finding a new one I ended up copying and then modifying one of the ones which is included. Before you do that try experimenting with the theme setting. The values you can use relate to the directories inside of blog-name/resources/templates/themes . Try switching from blue to nucleus to see what I mean.

If you want to create a new theme based on an included theme you should make a copy inside of the themes directory with a new name and you'll be good to go. There aren't too many types of pages and only a few css files so modification can be done in a relatively straightforward manner.

Deploying

Before you get the itch to deploy your site make sure to put your project into a repo.

Also, you'll need to know that when Cryogen builds your site it puts all of the newly created files inside of blog-name/resources/public directory. This directory is the one you need to copy to your server.

$ scp -r resources/public USER@SERVER:/PATTH/blog-name/

You'll notice that you can tag your posts from within the map at the head of each post file. In the tags vector enter a set of tag values. These are used to produce a list at your sites's /tags/ url.

For rss files you'll get an overall site file called feed.xml at your sites root. If you want a feed file based on a tag such as clojure see the rss-filters setting in the config.edn file. I personally see a need for myself to have feed files for clojure, python and java so my setting looks like the following. Edit yours as you see fit.

:rss-filters ["clojure" "python" "java"]

If you add your blog to Planet Clojure you'll want to submit your blog name along with your site's path to the clojure.xml file which you'll not see created in your site's root.

Summary

For more info on Cryogen see it's home page and GitHub repo.