Glue is a simple static site generator for Ruby that uses Haml, Sass and Textile/Markdown.
You can create static website so easily that you’ll imagine how could you live without it!
Glue has only what you’ll need:
- Partial support
- Automatic Sitemap & Feed from your pages
- Simple text writing using Markdown or Textile
- Beautiful and easy-to-maintain layouts using Haml & Sass
To install Glue, you’ll need a working Ruby installation with Rubygems. If you’re cool with it, just run the following command to install it.
sudo gem install glue-site
After installing Glue and its dependencies, you can create your site so easily! Just run the following command from your terminal window.
This command will create a
mysite directory with all the Glue structure.
Now you're ready to configure your Glue site.
All your site settings are defined in
There are 3 main blocks:
site: # Set default page title. title: "The awesome Glue!" # Set default page description description: "Glue is a simple static site generator for Ruby that uses Haml, Sass and Textile/Markdown." # Set default keywords keywords: "glue, ruby, haml, sass, static site, textile, markdown" # Set your base url. # Include domain and path (if needed). # Domain is required for sitemap generation. base_url: http://fnando.github.com/ # If you're using Apache you can enable `MultiViews` # or mod_rewrite and access your URL like # http://example.com/about instead of http://example.com/about.html friendly_url: true # Set your language for feeds and meta tags language: en-us sitemap: # Do generate sitemap enabled: true # Filters will be applied against full filename. # Use .*? to match all. Use regular expressions. filters: - .*? feed: # Do generate feed enabled: true # Filters will be applied against full filename. # Use .*? to match all. Use regular expressions. filters: - .*?
Views are placed in the "views" directory. All
.haml files will be exported as
respecting the structure you define.
So, if you create a file
views/index.haml, a correspondent
public/index.html will be exported;
if you create
views/articles/using-glue.haml, Glue will export it as
public/articles/using-glue.html, and so on.
To specify layouts, titles, descriptions and any other value you want, your document must have meta data. Meta data is nothing but Haml comments. Here's the meta data from this page you're viewing:
/ title: The awesome Glue! / description: Glue is a simple static site generator for Ruby that uses Haml, Sass and Textile/Markdown. / keywords: Glue, Ruby, Static Site, Haml, Sass, Markdown, Textile / layout: main / id: glue / tagline: Static site generator / version: 0.0.5
The are some meta data that is Glue-reserved.
Specify the layout your page is going to use. Layouts must be placed on
views/layouts. If you don't want to use a layout, set it to
When set to
yes, define if the current page should also exported as
public/index.html. The default is
When set to
no, the page is not added to
public/sitemap.xml. The default is
When set to
no, the page is not added to
public/feed.xml. The default is
There are some helpers that comes with Glue:
Parse a given text as Markdown code.
%p :markdown This text will be converted to HTML using [RDiscount](http://github.com/rtomayko/rdiscount/tree/master).You can call it directly:
%p= markdown("*Markdown* rules!")
Parse a given text as Textile code.
%p :textile This text will be converted to HTML using "RedCloth":http://redcloth.org/.You can call it directly:
%p= textile("*Textile* rules!")
Parse a given text as Haml code.
You can call it directly:
%p= haml("%strong Haml\nis so nice!")
Return an URL considering the
base_urlconfiguration option. If you want to retrieve a full URL (that include the host), set the option
%p= url_for("feed.xml", :full => true)
linktag pointing to your
Render will lookup for the path your provide, according to the file extension.
The example below will search for
footer.textile, rendering the first it founds.
To add your own helpers, use the file
Let's create a helper that reverses a given text.
module Helper def reversed(text) text.reverse end end
Just call it from your view like this:
%p = reversed("Some cool text!")
Notice that you need to return a string. DO NOT output directly;
use the equal sign like in
= reversed("Some cool text!")
If you want to output directly, use the
haml_concat method in your helper.
module Helper def reversed(text) haml_concat text.reverse end end
Then you can just call the helper.
%p - reversed("Some cool text!")
Capistrano & Dreamhost
Here's a simple deploy task for Capistrano & Dreamhost.
First, create a new domain/subdomain pointing to the
capify from the root directory. Edit the
pasting the sample below.
set :application, "howto" set :scm, :git set :repository, "firstname.lastname@example.org:USER/some-repo.git" set :deploy_to, "/home/USER/example.com" set :user, "USER" set :use_sudo, false role :web, "example.com"
cap deploy:setup to prepare your server.
To update your site, just run
Could not be easier!
This project was created by Nando Vieira.
Check it out another interesting projects at http://fnando.github.com.