Search code examples
rubymiddleman

Middleman - How to change the paths for generated html files?


I'm building a website using Middleman. There are source files placed like the following.

source/index.html.md
source/errors/404.html
source/docs/foo.html.md
source/docs/bar.html.md

By default, when I build static html files, the generated files are placed following to the original directory structure (with directory indexes).

build/index.html
build/errors/404/index.html
build/docs/foo/index.html
build/docs/bar/index.html

However, I want all html files to be served directly under /, so that they can be accessed like http://example.com/foo/ and http://example.com/404/.

How do you change the paths for generated html files?


Solution

  • You can use proxies to create duplicate pages, and then ignore the original pages.

    https://middlemanapp.com/basics/dynamic-pages/

    But the simplest way is, of course, to adjust the source structure to match the desired structure.