Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Static site-generator based on Scala & Scalate with RSS- & pagination capabilities
Branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
project whitespace

SiteGen - a static sitegenerator with RSS and pagination ability written in Scala

SiteGen is a simple static site generator written in Scala based on Scalate which outputs plain html and RSS as static files which you can deploy onto any webserver you like without any other dependencies.

The bulk of the code was largely thrown together over a few evenings, so it may not be an absolute thing of beauty, but it does what it says on the tin, and if you want to extends or improve upon it, feel free to fork and send pull requests!


SiteGen has the following featres:

  • Write markup in any format recognized by Scalate: plain html, Jade, Scaml, Mustache, SSP or Markdown
  • Support for layouts, nested layouts and different layouts for different pages
  • Pagination support, for instance for your blog/news page
  • RSS support: Generate an ordered RSS Feed from pages in a given directory
  • SEO friendly URL's - a "contact.html" markup page will be generated into a /contact/ URL.
  • Page generation time integration with Scala code

Basic usage

Download the SiteGen-1.0.jar file, then run:

java -jar SiteGen-1.0.jar [INPUTDIR] [OUTPUTDIR]

Yup, that's about it. If you follow the instructions below to create you site structure, that should give you a website with all the bells and whistles you may want from a static website.

Directory structure

A typical site may have the following structure:

- layouts
    - parent.layout.mustache
- static
    - css files, images, javascript etc (this can go anywhere, non SiteGen resources will be copied over as-is)
- index.mustache (your index page at /)
- blog
    - feed.rss (settings for your RSS feed)
    - 2012_10_08_some-post.mustache (will be generated into /blog/2012/10/08/some-post)
    - index.paginated.mustache (a paginated page containing posts)

Directory settings

Directory settings set basic things such as titles and layouts that are global for a directory unless overridden by a page. Settings are also inherited by sub-folders, again, unless they are overridden by in subfolders. Settings are a useful way of setting global model settings such as titles, contents of navs etc. All setting values MUST be valid Scala statements:

parent=layouts/htmlLayout.layout.mustache // sets parent layout, only exception to Scala expression rule
title="default title" // sets a default title


A layout may look something like this (hopefully relatively self explanatory):


Layouts MUST have an additional file-ending of ".layout.[mustache|jade|ssp|scaml]" to demarkate that they are indeed a layout file and not just a regular page. Layouts can also be inherited multiple levels, for instance:

<div> {{{content}}} </div>

The block at the start enclosed by "---" allows you to define/redefine properties, such as in this case telling that the layout should be rendered in the parent.layout.mustache (ie a layout embedded in a layout).


A page may provide it's own settings or override those provided by the directory by starting with a section at the top demarkated by "---" and ended in the same way, for example:

property="I'm a parent"
Parent greeting: {{greeting}}, {{{content}}}

If settings that are in a directory level setting are not overriden, these will also be used by the page.

RSS/Blog/paginated pages

For pages to be picked up and ordered by time correctly in RSS feeds and paginated pages, the settings block of the page will need to contain the following property (example):


Paginated Pages

Paginated pages/blog index pages are somewhat of a special case and are a little more involved, as they will effectively import content from multiple pages:

title="Recursivity - Blog"
<div class="span3">
    <strong>Recent Posts</strong>
<li><a href="{{uri}}">{{title}}</a></li>

<div class="span9">
    <h2><a href="{{uri}}">{{title}}</a></h2>


Prev: {{previousPage}}<br/>
Next: {{nextPage}}

In the example above, the "pageSize" model property tells the paginated page how many entries each index page will need to contain. The "navEntries" content block with its uri and title properties will contain links to the most recent posts. The "content"-block will contain the contents of the posts in the index page, hopefully the individual properties are somewhat self-explanatory. Furthermore, paginated pages require in the same way as layouts a special naming convention for instance index.paginated.mustache (where ".paginated." marks it s a paginated index page).

SEO friendly URL's

URL's for pages will automatically be generated on the following basis:

  • directory paths takes precedence.
  • pages named "index" will be interpreted as the root page of the current directory.
  • underscores in file-names will generate the appropriate directories, for instance "2012_10_07" becomes "/2012/10/07"
  • dashes will be retained in paths, for instance "some-post"
  • any page names such as "contact.html" will be given a friendlier URL of "contact/"

RSS Feeds

RSS feeds will pick up all posts in an ordered fashion in a directory that have the "published" property set on them (see above). The settings for the RSS feed needs to live in a feed.rss property file in the directory it is supposed to generate a feed for, and will have the following (example) format:

author=Wille Faler
title=sitegen test blog
description=this is the test rss feed

The feed will be generated as a "feed.xml"-file into the output directory in which the feed.rss file lives.

Something went wrong with that request. Please try again.