package raga

  1. Overview
  2. Docs
Simple static site generator

Install

dune-project
 Dependency

Authors

Maintainers

Sources

0.1.0.tar.gz
md5=6fcd2d93f274292f2df8df88cae69a1f
sha512=2a933a21d4ad6fdb7b730dac76e7799561b5dd44828a20783d9d8b7c8919af6dbb45a9c43c3b5edad7d62699e091a84ce9e96ffebd129f84251e9f4981b2d170

Description

Simple static site generator with Handlebars templating

README

Raga

Raga is a static site generator.

Installation

You need dune, opam, and ocaml to be pre-installed. Then run:

git clone https://github.com/nikochiko/raga
cd raga
opam install .

Usage

Directory Structure

raga works on a directory structure like this:

site/
├── config.huml
├── content/
│   ├── about.md
│   ├── home.md
│   └── posts/
│       ├── first-post.md
│       └── second-post.md
├── templates/
│   │── post.hbs
│   ├── home.hbs
│   └── partials/
│       └── header.hbs
└── static/
    ├── css/
    │   └── styles.css
    └── js/
        └── scripts.js
  • content/ contains markdown & other files for your site content. This is content that will be processed and converted to HTML.
  • templates/ contains Handlebars templates for rendering your content. path is configurable.
  • static/ contains static assets like CSS, JavaScript, and images that will be copied as-is to the output directory.

Configuration

This goes into config.huml:

title: "alice"
base_url: "https://alice.example.com"

pages::
  home::
    src: "home.md"
    dst: "index.html"
    tmpl: "home.hbs"
  rss::
    dst: "rss.xml"
    tmpl: "rss.hbs"
  posts::
    src:: glob: "{**/*,*}.md"
    excl::
      frontmatter:: draft: true
      glob: "{**/_*,_*}.md"
    dst: """
      {{ concat_path (chop_suffix src_path ".md") "index.html" }}
    """
    tmpl: "post.hbs"

params::
  social_links::
    github::
      url: "https://github.com/nikochiko"
      label: "gh/nikochiko"
    email::
      url: "mailto:k@kaustubh.page"
      label: "k@kaustubh.page"
  header_links::
    Home: "/"
    Blog: "/posts/"
  • title: The title of your website. This is available to templates as {{ site.title }}.
  • base_url: The base URL of your website. This is available to templates as {{ site.base_url }}.
  • pages: Defines the pages to be generated. Each page rule can specify:

    • src: The source files for this rule. This is a glob pattern relative to the content/ directory. This can also be omitted for pages that don't have a source file (e.g., RSS feeds).
    • excl: Exclusion patterns for source files. This supports:

      • glob: A glob pattern to exclude files.
      • frontmatter: Key-value pairs to exclude files based on frontmatter metadata.
    • dst: The destination path for the generated page. This can use template expressions. Required.
    • tmpl: The Handlebars template to use for rendering this page. This is relative to the templates/ directory. Required.
  • params: Custom parameters that can be accessed in templates via {{ site.params.<param_name> }}.

Look at examples/blog for a complete example.

CLI

To generate the site, run this command from the root of your site directory:

raga . --output ./_site

The website will be built to the _site directory by default.

LICENSE

MIT.

Dependencies (8)

  1. ptime
  2. uri
  3. omd >= "2.0.0~alpha1"
  4. re >= "1.10.3"
  5. huml >= "0.1.1"
  6. handlebars-ml >= "0.3.0"
  7. ocaml
  8. dune >= "3.20"

Dev Dependencies (1)

  1. odoc with-doc

Used by

None

Conflicts

None