OurBigBook logoOurBigBook Docs OurBigBook logoOurBigBook.comSite Source code
The following variables are defined for usage inside your ourbigbook.liquid.html file:
  • body: the rendered body
  • dir_relpath: relative path from the rendered output to the _dir directory. Sample usage to link to the root directory listing:
    <div><a href="{{ dir_relpath }}{{ html_index }}">Website source code</a></div>
  • file_relpath: similar to raw_relpath, but link to the _file output directory instead
  • git_sha: SHA of the latest git commit of the source code if in a git repository
  • github_prefix: this variable is set only if if the "github" media provider. It points to the URL prefix of the provider, e.g. if you have in your ourbigbook.json:
    "media-providers": {
      "github": {
        "remote": "mygithubusername/media"
      },
    then you can use media from that repository with:
    <img src="image/x-icon" href="{{ github_prefix }}/myimage.jpg" />
  • html_ext: .html for local renders, empty for server renders.
    So e.g. to link to an ID myid you can use:
    <a href="{{ root_relpath }}myid{{ html_ext }}">
    This will ideally be replaced with a more generic link to arbitrary ID mechnism at some point: github.com/ourbigbook/ourbigbook/issues/135
  • html_index: /index.html for local renders, empty for server renders
  • input_path: path to the OurBigBook Markup source file relative to the project toplevel directory that generated this output, e.g. path/to/myfile.bigb
    May be an empty string in the case of autogenerated sources, notably automatic directory listings, so you should always check for that with something like:
    {% if input_path != "" %}
    <div>Source code for this page: <a href="{{ raw_relpath }}/{{ input_path }}">{{ input_path }}</a></div>
    {% endif %}
  • is_index_article. Boolean. True if the toplevel being rendered on this output file is the the index article. E.g. in:
    index.bigb
    = John Smith's homepage
    
    == Mathematics
    with split header conversion, the value of is_index_article would be:
    • index.html: true
    • split.html: true
    • mathematics.html: false
  • json: exposes the entire ourbigbook.json to the template. This is useful for example to obtain publishRootUrl as in:
    <meta property="og:image" content="{{ json.publishRootUrl }}/{{ raw_relpath }}/logo.svg">
  • raw_relpath: relative path from the rendered output to the _raw directory. Should be used to prefix all non-OurBigBook Markup output resources, which is the directory where such files are placed during conversion, e.g.
    <link rel="shortcut icon" href="{{ raw_relpath }}/logo.svg" />
  • root_page: relative path to the toplevel page, e.g. either index.html, ../index.html locally or ./, ../ on server oriented rendereing
  • root_relpath: relative path from the rendered output to the toplevel directory.
    This allows for toplevel resources like CSS to be found seamlessly form inside subdirectories, specially when rendering locally.
    For example, for the toplevel CSS main.css which is generated from main.scss, we can use:
    <link rel="stylesheet" type="text/css" href="{{ root_relpath }}main.css">
    Then, when a file is locally, for example under a subdirectory mysubdir/myfile.html, OurBigBook will set:
    root_relpath=../
    giving the desired:
    <link rel="stylesheet" type="text/css" href="../main.css">
    And if the output path were instead just myohterfile.html, root_relpath expands to an empty string, giving again the correct:
    <link rel="stylesheet" type="text/css" href="main.css">
    This will ideally be replaced with a more generic link to arbitrary ID mechnism at some point: github.com/ourbigbook/ourbigbook/issues/135
  • server_path: path part of the URL at which the output of this template will be visible on the server. For example:
    • index.bigb:
    • notindex.bigb:
    This variable can be useful if you need to generate the full path to a given page for an insane system such as og:url:
    <meta property="og:url" content="{{ json.publishRootUrl }}{{ server_path }}">
  • style: default OurBigBook stylesheets
  • title: a plaintext version of the page title without any HTML tags which will is suitable for the <title> element
  • toplevel_id: ID of the toplevel header of a page, e.g. given and -S, --split-headers:
    = My homepage
    
    == Mathematics
    {scope}
    
    === Chain rule
    we'd get;
    • /: empty string
    • /split: empty string
    • /mathematics: mathematics
    • /mathematics/chain-rule: mathematics/chain-rule
Template variable expansion automatically escape special HTML characters such as <. TODO: " however is not currently escaped: github.com/ourbigbook/ourbigbook/issues/375 but it would be better if it were.

Ancestors (4)

  1. --template
  2. OurBigBook CLI options
  3. OurBigBook CLI
  4. Home