anodize v2.6.0
Anodize is a static site generator that allows you to create no-frills websites from simple templates. It has several useful website features built-in; the philosophy is to have sane defaults rather than to allow excessive configuration.
Differentiating features:
- Templating within markdown: Anodize will parse templates inside the body of your markdown files, for things like lists of pages or files
- Incremental regeneration (beta): Automatically skip re-rendering files that haven't changed
- Global variables: Declare variables in your configuration file and access them anywhere
Getting started:
$ npm install -g anodize$ cd your/website/directory$ anodize init
How it works
Anodize stores all config in the .anodize.yml file in the project root folder, which is assumed to be the current working directory unless the -i flag is passed.
There are three subdirectories in the project root:
templatestores Liquid templates for rendering the website.srcstores all of the source files.genis the output folder for the rendered HTML. The name of each of these folders is configurable in.anodize.ymlunder the keystemplate,source,targetrespectively.
Source folder
Files in the source folder are either markdown files (everything with a .md extension) or static files (everything else). Static files are simply copied over to the target directory under the same relative path.
Markdown format
Markdown parsing is done by ShowdownJS. Each file contains:
- a YAML header
- one line with only
--- - a markdown body
title: My first post
sort: 5
some_key: true
this:
- is
- yaml
---
## this is markdown
Anything here can be templated in Liquid. For example: this is {{ keys.some_key }}.Index files (index.md) and other markdown files are treated differently.
Non-index files
The header can contain any keys with any values, except for the following special keys:
titleis used in the HTML<title>tag, through the titleTemplate (see below) if presentdateif in the formatYYYY-MM-DDorYYYY-MMis parsed into a Unix timestampdraftis a boolean that indicates the current file is a draft and should not be rendered, allowing you to include the file in version control without displaying it in productionheadrepresents the HTML head. Currently only supported for internal use, so consider this key reserved.regenis a boolean that enables site-wide access in the body template. This flag tells Anodize to regenerate this file regardless of changes when doing incremental regeneration.keywordsis an array of keywords to be placed in the<meta keywords>html tag.layoutidentifies the name of the template file, and if not present, Anodize will look for a file with the name of the parent directory and the.liquidextension./foo/bar.mdwill default to<template directory>/foo.liquid.
Standard markdown files have access to the following keys through templates in their body.
keysis the header object of the fileglobalis the object declared under the key of the same name in.anodize.ymlidis the filename of the current filepathis the path that the current file will be accessible at after generationdirnameis the name of the parent directory, or_rootif the file is in the website root.siteis accessible ifregenis enabled in the header. It is an object with keys in the formatpath/to/directoryand values{ filename: file_object }. Many of thefile_objectproperties are internal, but naturally the header is accessible underfile_object.keys. For example, if I wanted to enumerate the files in a directoryfoo/bar:
{% assign dir = site['foo/bar'] | sortItems %}
{% for f in dir %}{{ f.id }}{% endfor %} The Liquid filter sortItems is provided to convert objects into arrays and sort based on the sort key if present, or alphanumerically otherwise.
Index files
Index files have access to the same keys as regular files, with the following differences:
sortBytells the sortItems filter which key to sort the folder byno-regenis used instead ofregenfor conciseness; index files are regenerated by default, andno-regendisables this behavior. Sositeis accessible by default in index files.layoutdefaults toindex.liquidrather than the name of the parent directory.
Index files are also discard by the sortItems filter for convenience.
All markdown files are output as the index file of their own directory; this is known as a 'pretty url.' /foo/bar/baz.md will be output to /foo/bar/baz/index.html and can be located by a browser at https://example.com/foo/bar/baz/.
Templates
Anodize uses the Liquid templating language through liquidjs.
Server
Anodize comes with live-server, a development webserver with live reloading. Just run$ anodize serve
and open http://localhost:8000 in a browser.
Configuration
Settings are defined in a file named .anodize.yml, which is automatically created by running anodize init.
As previously stated the keys target, source, and template specify the locations of those directories.
The key ignore is an array of glob patterns to ignore. Default is all dotfiles **/.*.
The key head specifies the contents of the <head> tag. Available sub-keys and corresponding tags:
title: string,<title>description: string,<meta name="description">keywords: array,<meta name="keywords">css: array of file paths,<link rel="stylesheet" href="path/to/file.css">raw: array, inserts specified text into<head>.
The contents of the key global are available to the templating engine under the key global.
The key titleTemplate is a template for constructing html <title> tags. It is a string with a $0 where you want the page's title inserted. For example, the string $0 | Sid Mani's blog. Defaults to $0 (no templating).
About
I wrote this to power my blog. If you do something cool with this, a link back here or to my blog would be nice. Feel free to open pull requests.
License
GNU-AGPLv3
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago