[!NOTE] Gearchiveerde versie: Dit spiekbriefje behandelt Middleman v3. Raadpleeg voor nieuwere installaties de Middleman v4+ documentatie.
Middleman is een statische site-generator geschreven in Ruby volgens moderne webontwikkelingsstandaarden.
Configuratie (config.rb)
Mappen & Assets
set :css_dir, "stylesheets"
set :js_dir, "javascripts"
set :images_dir, "images"
# Automatische afbeeldingsafmetingen op image_tag helper
activate :automatic_image_sizes
Compass-integratie
compass_config do |config|
config.output_style = :compact
end
Paginaroutering & Layouts
# Schakel layout uit voor raw HTML- of XML-templates
page "/sitemap.xml", layout: false
# Wijs alternatieve layout toe
page "/admin/*", layout: :admin_layout
# Groepeer meerdere paden onder één layout
with_layout :docs do
page "/guides/*"
page "/api/*"
end
# Proxy-pagina's
page "/about.html", proxy: "/template-page.html" do
@page_title = "About Us"
end
Aangepaste helpers
helpers do
def format_currency(amount)
"$%.2f" % amount
end
end
Build-configuratie
Optimaliseer assets alleen bij uitvoeren van middleman build:
configure :build do
activate :minify_css
activate :minify_javascript
activate :cache_buster
activate :relative_assets
# Voeg aangepast CDN-pad toe aan assets
# set :http_path, "https://cdn.example.com/"
end