Skip to content
Go to file

Latest commit


Git stats


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


Sitepress is a file-backed website content manager that can be embedded in popular web frameworks like Rails, run stand-alone, or be compiled into static sites. Its useful for marketing pages or small websites that you need to deploy within your web frameworks.

Build Status Code Climate


Rails Installation

Follow the instructions in the Sitepress Rails gem.

Standalone Installation

Add this line to your application's Gemfile:

gem 'sitepress'

And then execute:

$ bundle

Or install it yourself as:

$ gem install sitepress


Given a the file hi.html.haml:

title: Name
  keywords: One

    %h1 Hi
    %p This is just some content
    %h2 There

Sitepress can parse out the frontmatter and body to render inside your framework of choice, like Rails:

class SitepressController < ApplicationController
  def show
    sitepress.render "/hi"

so when you call from your templates, you get something like this:

=> {"title"=>"Name", "meta"=>{"keywords"=>"One"}, "toc"=>["Hi", "There"]}
>"meta", "keywords")
=> "One"

Sitepress is designed to be embedded in rails and other Ruby web frameworks.


Sitepress implements a subset of the best features from the Middleman static site generator including the Site and Frontmatter.


Frontmatter is a way to attach metadata to content pages. Its a powerful way to enable a team of writers and engineers work together on content. The engineers focus on reading values from frontmatter while the writers can change values.

title: This is a swell doc
  keywords: this, is, a, test
background_color: #0f0

    %meta(name="keywords" value="#{"meta", "keywords")}")
  %body(style="background: #{["background_color"]};")["title"]
    %p And here's the rest of the content!


The Site accepts a directory path

> site = "spec/pages")
=> #<Sitepress::Site:0x007fcd24103710 @root=#<Pathname:spec/pages>, @request_path=#<Pathname:/>>

Then you can request a resource by request path:

> resource = site.get("/test")
=> #<Sitepress::Resource:0x007fcd2488a128 @request_path="/test", @content_type="text/html", @file_path=#<Pathname:spec/pages/test.html.haml>, @frontmatter=#<Sitepress::Frontmatter:0x007fcd24889e80 @data="title: Name\nmeta:\n  keywords: One", @body="\n!!!\n%html\n  %head\n[\"title\"]\n  %body\n    %h1 Hi\n    %p This is just some content\n    %h2 There\n">>

And access the frontmatter data (if available) and body of the template.

=> {"title"=>"Name", "meta"=>{"keywords"=>"One"}}
> resource.body
=> "\n!!!\n%html\n  %head\n[\"title\"]\n  %body\n    %h1 Hi\n    %p This is just some content\n    %h2 There\n"

Resource globbing

The Site API is a powerful way to query content via resource globbing. For example, if you have a folder full of files but you only want all .html files within the docs directory, you'd do something like:

  -site.root.glob("docs/*.html*").each do |page|
    %li=link_to["title"], page.request_path


After checking out the repo, run bin/setup to install dependencies. Then, run rake spec to run the tests. You can also run bin/console for an interactive prompt that will allow you to experiment.

To install this gem onto your local machine, run bundle exec rake install. To release a new version, update the version number in version.rb, and then run bundle exec rake release, which will create a git tag for the version, push git commits and tags, and push the .gem file to


Bug reports and pull requests are welcome on GitHub at


Sitepress ruby gems



No packages published