Skip to content
A static blog generator implemented in Go.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.


Type Name Latest commit message Commit time
Failed to load latest commit information.



A static blog generator implemented in Go. This all started when looking for a static blog tool. I asked around in my local Linux user group and one of them joked you could write your own over a weekend. Mission accomplished.


You'll want go installed on your system, then you just need to

go get

This will install the binary goblog into $GOPATH/bin. In this case, you have to set properly GOPATH and GOROOT. Alternatively, you can download the source and do it yourself.


All directory locations are configurable, but it is generally considered wise to have a single place for your blog.

The default blog directory structure is this:

$ ls
blogs  public  static  templates
  • The blogs directory contains all of your blog entries. Each file within that directory or any sub-directory that ends in .md will be processed as a blog entry. The rest of extensions will be ignored. Goblog uses markdown (like github), so feel free to mark down your blog.

  • The public directory is where your generated code will go. You'll want to point your web server to that location.

  • The static directory contains static assets like CSS, JavaScript, images, etc that your blog needs to function.

  • The templates directory contains a list of html templates to use when generating the site. Each of the templates use Go's templating system to display specific values. You can see my own blog for an example.


Each of the following templates are required. Without them, the system cannot generate the static pages.

  • The site.html template is the template for every page.
  • The archive.html template is used for printing a list of all your blog entries.
  • The about.html template is used for displaying information about yourself.
  • The entries.html template is used to display multiple blog entries on the index.html page.
  • The entry.html template renders a single blog entry.
  • The tags.html template renders all of the blog tags into a page.

Each template is rendered using Go's standard text/template library. When designing your templates, you can reference the documentation for the templates package. For example, the entry.html maps to the MakeBlogEntry function. In your entry.html template, you'd put {{.Title}} where you expect the title of the blog entry to go. You can see an example at my own entry.html.

As a special case, the templating engine has some helper functions:

  • .Exec - you can include the output of a command line using this helper. For example, {{.Exec "/bin/bash" "-c" "git log --pretty=oneline | wc -l "}} would return the results of the executed command which might be something like 30.

Blog Entry Meta Data

You could specify meta data about a blog (title, created, etc.). Contrary to other static blog generator which use YAML headers within markdown file for setting fields, Goblog use XHTML comments for that. That is, if we want to set a tag with name Foo with bar value, we have to write:

<!-- Foo: bar -->

An example can be found at

The meta data fields which Goblog recognizes are:

  • Title: Title of the post, without quotes. Example: Title: This if my first post
  • Author: The author of the post. Example: Author: Joshua Marsh
  • Description: A brief description of the blog. This will be used by things like RSS feeds. Example: Description: This is my first blog entry!
  • Languages: This is the language the entry is in. This can be used to set html headers in your templates. Example: Languages: en
  • Tags: A list of tags. Example: Tags: linux, oss, informatics
  • Created: Data of creation of the post. The format of the date is YYYY-MM-DD. If this is not set, it will default to the timestamp of the file on the file system. Example: Created: 2013-07-18
  • Updated: Data of last update of the post. The format of the date is YYYY-MM-DD. If this is not set, it will default to the timestamp of the file on the file system. Example: Updated: 2013-07-18

All of these values are optional. They are mapped to your template. If you don't specify them in your blog entry but have them in your templates, then they obviously won't show up. You should try to specify all the values your templates have in them to make your site appear normal.

You can’t perform that action at this time.