PieCrust

Baking your website

Baking” is the PieCrust name for transforming your website into a bunch of static HTML files.

Why and when to bake

There are quite a few advantages for doing so:

  • You get the fatest website possible.
  • You barely use any of your web-server’s resources.
  • There are no security holes in your website.

When to bake:

  • You have a very high traffic website, or expect/hope to have high traffic in the near future.
  • You have a blog section with many articles, or with lots of categories and/or tags (this is where PieCrust doesn’t scale well compared to SQL-enabled CMS engines).
  • You don’t have PHP 5.3+ on your web server.
  • You just don’t want to worry!

Running the baker

You run the baker through chef with the bake command. Type chef bake --help for a detailed usage.

In the most simple case, baking your website is done like this (if you’re already in your website’s root directory):

chef bake

This would bake the website found at the current directory (it should contain _content) into a sub-directory named _counter.

If you want to bake into a specific output directory, from a specific root directory, type:

chef bake -o /path/to/output  --root /path/to/root

For example, with the recommended PieCrust directory structure, you would set the output folder to the mywebsite.com folder.

On top of baking all the PieCrust content (pages, posts, tags, categories, etc.), chef also bakes any other file found in the root directory. In most cases it means just copying stuff over (images, CSS stylesheets, etc.), but sometimes it also means processing the file along the way. See the section on file processors for more information.

Customizing the baking

Specifying tag combinations

By default, chef will bake any tag combinations that you used in your site through a pctagurl template function. But if you want a tag combination to be available for linking from outside of your site, or if you didn’t use the pctagurl function, you can specify tag combinations to bake in the baker/tag_combinations configuration setting. For example:

baker:
    tag_combinations:
        - kids/photos
        - some-tag/some-other-tag
        - tag1/tag2/tag3

You can specify tags in whatever order you want, but only that order would be baked (kids/photos is a different URL than photos/kids, even if the contents are likely to be identical).

Specifying configuration variants

Sometimes you want to bake a website with slightly different configuration settings than when you preview it.

A common case is the site/root setting, which defines the base URL for a website. When previewed, you generally want PieCrust to figure out what that base URL is (something like http://localhost:8080/mywebsite/). However, when you bake it, you want a specific base URL like http://mydomain.com. Well, you can do this with the baker/config_variants setting:

baker:
    config_variants:
        default:
            site:
                root: http://mydomain.com

The default configuration variant is the one chef will use by default when baking. You can specify another configuration variant via command line options if you need multiple variants:

chef bake -c other_variant
Fork me on GitHub