1. Writing a BML Scheme

BML is essentially a simple macro language. Macros are called templates in BML. Templates are defined in lookup files and are invoked in BML files. Templates accept parameters and are divided into several types according to how parameters are transmitted and how the definition of the template is able to make use of them. Definitions of templates are essentially chunks of HTML with potentially more recursive BML template invocations inside them.

For LiveJournal, the most common templates are defined in the file $LJHOME/cgi-bin/bml/scheme/global.look; all other schemes either replace all of the templates, or inherit whichever is not replaced.

To write your own scheme, all you have to do is write your own BML lookup file that uses the same templates as $LJHOME/cgi-bin/bml/global.look. Then, implementing a new scheme becomes pretty painless:

Procedure 20.1. Creating a new BML scheme: foo:

  1. Create a new file under $LJHOME/cgi-bin/bml/scheme, labeled after the scheme name (foo). For example: $LJHOME/cgi-bin/bml/scheme/foo.look. This file should contain all of the BML directives you have written for your unique layout. The first line in this file should be


  2. If you don't have a local BML configuration file (_config-local.bml) in your $LJHOME/htdocs directory, you should create one now. The contents of that file should look like:

    Example 20.1. Sample _config-local.bml

    DoGZIP 1
    DefaultLanguage en_YS
    DefaultScheme foo

  3. Manually restart the Apache process.

After you have written your scheme, consider adding it to the array in @LJ::SCHEMES, so that your users can use their preferred scheme. You can also add a thumbnail preview image of your front page into htdocs/img/schemethumb, and link to it from that array.