https://github.com/ocramz/twelve
Like @11ty , but this goes up to 12
https://github.com/ocramz/twelve
html-parser html-template-engine html-templating static-site-generator static-website-generation template-engine
Last synced: about 1 month ago
JSON representation
Like @11ty , but this goes up to 12
- Host: GitHub
- URL: https://github.com/ocramz/twelve
- Owner: ocramz
- License: bsd-3-clause
- Created: 2020-12-09T12:36:48.000Z (almost 5 years ago)
- Default Branch: main
- Last Pushed: 2021-01-26T20:04:40.000Z (over 4 years ago)
- Last Synced: 2025-04-21T18:24:26.714Z (6 months ago)
- Topics: html-parser, html-template-engine, html-templating, static-site-generator, static-website-generation, template-engine
- Language: Haskell
- Homepage:
- Size: 70.3 KB
- Stars: 5
- Watchers: 2
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# twelve

Like [11ty](https://www.11ty.dev/), but this goes to 12.
## What
`twelve` is a small and simple static site generator, inspired by 11ty.
## Why
`twelve` was created to achieve these goals :
* Modularity
* Ease of use
## Why, in detail
The main rationale for this project, and its claim to enabling a modular approach in website construction, is the following :
`twelve` flips the templating logic of 11ty on its head : it lets you reference directly a content splice from within a container template, rather than declaring the name of a layout file from within the file containing the content splice.
For example, say we want to splice the content of `card1.html` into some list items within `base.html` :
```html
- {{ card1.html }}
- {{ card1.html }}
```
```html
```
Let's try building `base.html` and look at the result :
```
$ twelve build -f base.html
```
```
$ cat _site/base.html
```
```html
-
Hello from card 1 !
-
Hello from card 1 !
```
This means that you can develop webpage sections in isolation (e.g. navbar, hero sections etc.), and easily reuse them in multiple places within `base` or other files that mention them.
### Note
* Template files should be valid HTML splices, i.e. cannot be bare text.
* All input files and templates should have an `.html` file extension.
* Template files can reference other ones up to an arbitrary depth, as long as the reference graph is acyclic. If you do have two templates that reference each other, well, you're asking for trouble.
## Why, in full
Modern websites tend to accrete large amounts of CSS annotations around their HTML tags, and a module system can help in writing easily maintainable websites from reasonably-sized components.
In addition, many website build tools and templating languages try to do too much or to impose many design constraints upon the user. `twelve` aims to help without getting in the way.
## Installation
First, you need to have the [`stack` build tool](https://haskellstack.org) already set up on your machine.
Then, build and copy the `twelve` binary to a local `bin` directory with
$ stack install
You can see where the tool will be installed with
$ stack path --local-bin
Please refer to the `stack` manual for details.
## Usage
```
$ twelve
twelve, a little static website build tool
Usage: twelve COMMAND
twelve lets you build an HTML page from a collection of templates. Please
refer to the README for details. github.com/ocramz/twelve
Available options:
-h,--help Show this help text
Available commands:
init Initialize a 'twelve' project
build Build an HTML page
```
`twelve` has two commands:
* `init` initializes a project in the current directory, if there isn't one already (i.e. it creates a config file and the input and output directories using the command line options `-i` and `-o`). The input directory contains the HTML templates that will be used for populating the final result.
The default directories can be overridden with command line parameters.
* `build` does the whole work : produces a full HTML file by starting from a given input template file and splicing in the content of all references:
```
$ twelve build
Usage: twelve build [[-i|--dir-in DIR] [-o|--dir-out DIR]] -f FILEPATH
Build an HTML page
Available options:
-i,--dir-in DIR input directory for HTML
templates (default: "_templates")
-o,--dir-out DIR output directory (default: "_site")
-f FILEPATH path of input file
```
By default `build` will try to use the `twelve.json` config file. If that's not found, `twelve` will use the command line defaults, which can also be overridden here.
## Contribute
The aim of this project is to be simple and straightforward to use; PRs welcome !