XStatic—Smart Static Site Generator

A smart, static site generator that automatically manages dependencies to achieve blazing build times with minimal cognitive load. Only new and changed files, and files upstream of a changed dependency are processed. Renders markdown or embedded-Ruby (Erb-like) content as HTML.

Supports templates (embedded & layout), which may be included within content sources or other templates. Document metadata may me added using a plain-text preamble of key-value pairs. Generates a complete website that can be served by the built-in WEBrick server.

XStatic is just a Rake application with some magic sprinkled on top.

Markdown and Erb content are transformed with a custom Erb processor. This allows you to add application logic to your markdown content, for example fetch records from a database. All other content, such as HTML, CSS, and images, are hard linked to the destination directory, ready to be served or copied to a remove production server.

Examples

Here’s an example command sequence to get a project up and running.

$ mkdir myproject
$ cd myproject

$ xstatic init                    # set up initial project files
$ find . -type f
./content/index.md                # markdown content & metadata
./content/default.css             # asset to be hard linked under ./site
./templates/layouts/default.erb   # layout template used to render index

$ xstatic site                    # build website under ./site
updated ./site/index              # markdown & metadata converted to HTML
$ find ./site
./site                            # complete static site ready to be served
./site/index                      # generated HTML file
./site/default.css                # hard linked asset

$ xstatic start                   # start WEBrick server on port 2000
$ xstatic stop                    # stop WEBrick server

The above sequence can be simplified to a single command:

$ xstatic init site start         # and you're ready to go!

Site Development Process

Just follow this simple 5-step process as you build your site:

  1. Add assets and content to the content directory.

  2. Factor out code and data (HTML, Erb, markdown, plain text, etc.) to the templates directory.

  3. Create custom layouts in the templates/layouts directory.

  4. Update the site by running xstatic.

  5. Reload localhost:2000 in your browser to see your changes.

Homepage

ecentryx.com/gems/xstatic

Ruby Gem

rubygems.org/gems/xstatic

History

  1. 2022-02-24, v0.1.0

    • First public release.

License

(ISC License)

Copyright © 2022, Clint Pachl <[email protected]>

Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.

THE SOFTWARE IS PROVIDED “AS IS” AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.