Exporting the Static Site
Building the site with
Finally, when you are ready to deliver static code or, in the case of "blog
mode", host a static blog, you will need to build the site. Using the
command-line, from the project folder, run
$ cd my_project $ bundle exec middleman build
This will create a static file for each file located in your
Template files will be compiled, static files will be copied and any enabled
build-time features (such as compression) will be executed. Middleman will
automatically clean out files from the build directory for you that are left
over from earlier builds but would no longer be produced.
Deploying the site
After building the site you have everything you need within the
build-directory. There are nearly limitless ways to deploy a static build. So
we present our very own solution for this here. Feel free to search the web or
look at our extension directory for more alternatives to deploy Middleman. If
you are an author of a deployment tool suitable to deploy Middleman, please
open a pull request to the directory.
A very handy tool to deploy a build is
middleman-deploy. It can deploy a
site via rsync, FTP, SFTP, or Git.
$ middleman build [--clean] $ middleman deploy [--build-before]
Production Asset Hashing & CDN Configuration
A common setup for production is to hash your assets and serve them through a CDN. You can do this easily with Middleman: