Questions tagged [middleman]

Use the popular Ruby Sinatra (Rails-like) Tool chain to build static websites. Build your source files in Markdown, HAML, Textile (or many others), and take advantage of SASS with Compass for styling. Add Javascript, CoffeeScript and Sockets. View the sites locally with the built-in server mode before building static pages. Includes international (i18n) support. Mix in YAML data files and custom Ruby extensions if needed. Unlimited Buzzwords Galore!

Middleman is a static site generator based on Sinatra (a Rails-like Ruby based tool chain). It incorporates dozens of templating languages (Haml, Sass, Compass, Slim, CoffeeScript, and more). It makes minification, compression, cache busting, Yaml data (and more) an easy part of your development cycle.


Typical Development Cycle

This is the typical development cycle with Middleman:

  • Run middleman init projectname
  • Start the server with middleman server
  • Modify the files in the directory projectname while viewing them in your browser at http://localhost:4567
  • When you're happy with the files, run middleman build
  • Copy the generated static files from projectname/build to your webserver

Having the server available while developing turns out to be critical, as it allows quick review of changes ( For auto-reload, use middleman-livereload gem). This isn't as much of an issue with "normal" static site generators, but when you start adding partials, SCSS, Compass and the other goodies, that Middleman supports, server mode is invaluable.

Resources

553 questions
16
votes
6 answers

Static web site generation

I need an easy way to generate static web pages so that I can serve them up with Apache or Nginx. Currently I am using SproutCore's build tool (Abbot) to generate static pages but that is a little bit cumbersome as it is designed for building…
16
votes
2 answers

Get Current Path of Page in Middleman Layout File

Is it possible to retrieve the current path of a page in a middleman file? For instance, if I have a layout file layout.erb with something like the following: <%= page.path %> <%= yield %> and a test file index.html: Testing then when Middleman…
LandonSchropp
  • 10,084
  • 22
  • 86
  • 149
15
votes
2 answers

Deploy path doesn't work for Git Deploy Method in middleman-deploy

I am using middleman-blog and middleman-deploy. What I would like to do, is within the branch I am deploying to, I want the static files to be deployed to a subfolder within the repo (i.e. not the root folder). I tried doing this in my…
marcamillion
  • 32,933
  • 55
  • 189
  • 380
13
votes
3 answers

Using MIddleman 3.0 - How do I set individual page titles on dynamic pages?

I'm putting together a simple portfolio site in middleman. I'm generate the 'work' pages dynamically based on local YAML data. This is in the config.rb: data.work.projects.each do |project| page "/work/#{project[0]}.html", :proxy =>…
Jan Drewniak
  • 1,316
  • 15
  • 18
12
votes
2 answers

How do I create root-relative links in a static site?

When building a static HTML site, you can set the base url like so . Supposedly when you insert, say, an image, you can do so from that base url like so , which is equivalent to…
sea_monster
  • 659
  • 3
  • 8
  • 18
11
votes
1 answer

GitHub Pages trailing slashes

Using Middleman on GitHub Pages with directory_indexes enabled, I wonder if I can somehow get rid of the trailing slash GitHub adds. My urls are basically: /foo-bar -> /foo-bar/index.html. Visiting /foo-bar on GitHub Pages redirects to /foo-bar/. Is…
jgillich
  • 71,459
  • 6
  • 57
  • 85
11
votes
3 answers

How to know in what environment the code runs?

In the layout file of haml I would like to determine whether we are in our development and build environments. We're using Middleman. I would like to do something like this: - if environment == 'development' / Development Code =…
IgalSt
  • 1,974
  • 2
  • 17
  • 26
10
votes
1 answer

middleman console: how to use it?

I would like to know how to use middleman console. Is it a simple irb? What can I do with it that differs from the simple irb? middleman console [options] # Start an interactive console in the cont... I have some articles and I try to do…
Papouche Guinslyzinho
  • 5,277
  • 14
  • 58
  • 101
10
votes
1 answer

Cloudfront/S3: Server different file depending on Request Header

I am hosting a static website generated with Middleman on CloudFront and S3. I want to add multiple language support and middleman allows me to localize the content and have the english version at /index.html and the translated content at…
10
votes
4 answers

Middleman and Github pages

I'm trying to create a static site using Middleman. The git repo master has the source files. The static files are generated in the build folder which is in .gitignore. I have a branch gh-pages for Github pages. How do I setup things such that the…
Akshay Rawat
  • 4,714
  • 5
  • 40
  • 65
9
votes
2 answers

How can I generate a navigation in Middleman?

I'm just getting used to Middleman and Ruby in general. What's the best way to generate a navigation with active states?
Robert Cordes
  • 381
  • 2
  • 14
8
votes
2 answers

Middleman: run custom action after build

How can I run custom action (eg. copy file to build folder) after middleman built pages? I want to put Readme.md file from source to build dir.
NARKOZ
  • 27,203
  • 7
  • 68
  • 90
7
votes
2 answers

Getting error: dyld: Symbol not found: _clock_gettime

I want to start a middleman with command middleman server and when I do I get an error: dyld: lazy symbol binding failed: Symbol not found: _clock_gettime Referenced from:…
Kira
  • 1,575
  • 4
  • 26
  • 48
7
votes
2 answers

Ruby on Rails separate front & back

I've been using Ruby on Rails since a little more than one year now and I've always do it in a casual way, I mean, everything in one place (front & back), using the standard .html.erb file populated by the associated controller method. Otherwise,…
ZazOufUmI
  • 3,212
  • 6
  • 37
  • 67
7
votes
1 answer

How to rendering partials within a partials in middleman

I have some Haml partials, many of which contain the boilerplate .container .row .col-lg-12 When I try to abstract that out ala = partial "site_section", I get: syntax error, unexpected keyword_end, expecting end-of-input…
Walrus the Cat
  • 2,314
  • 5
  • 35
  • 64
1
2 3
36 37