uzu

uzu

Static site generator with built-in web server, file modification watcher, i18n, themes, and multi-page support.

Name Last Update
bin Loading commit data...
lib Loading commit data...
logotype Loading commit data...
t Loading commit data...
.gitattributes Loading commit data...
.gitignore Loading commit data...
.gitlab-ci.yml Loading commit data...
LICENSE Loading commit data...
META6.json Loading commit data...
README.md Loading commit data...

Uzu (渦) build status

Uzu is a static site generator with built-in web server, file modification watcher, live reload, i18n, themes, and multi-page support.

Features

  • Easy to use: Based on existing static site generator conventions
  • Built-in development webserver: Test your modifications (http://localhost:3000) as you work
  • Auto Re-render: uzu watch monitors the theme/[your-theme]/layout/, pages, partials/, and i18n/ folders for modifications and auto-renders to build
  • Live reload: uzu watch automatically reloads the browser when a re-render occurs
  • i18n support: Use YAML to define each language in the i18n/ folder (e.g. i18n/en.yml)
  • Page / layout support: Generate individual pages wrapped in the same theme layout
  • Trigger rebuild manually: Press r enter to initiate a full rebuild. This is useful for when you add new files or modify files that are not actively monitored by uzu, e.g. images, css, fonts, or any non .tt or .yml files
  • Actively developed: More features coming soon (e.g. more tests, AWS, Github Pages, SSH support...)

Note: Uzu is a work in progress. It is functional and does a bunch of cool stuff, but it isn't perfect. Please post any issues you find.

Usage

Usage:
  uzu init          - Initialize new project
  uzu webserver     - Start local web server
  uzu build         - Render all templates to build
  uzu watch         - Start web server and re-render
                      build on template modification
  uzu version       - Print uzu version and exit

Optional arguments:

  --config=         - Specify a custom config file
                      Default is `config`

  e.g. uzu --config=path/to/config.yml init 

  --no-livereload   - Disable livereload when
                      running uzu watch.

Config

Each project has its own config.yml which uses the following format:

---
# Name of the project
name: uzu-starter

# Languages to use, determines which
# i18n/*.yml file to use for string variables
#
# The first language in the list is considered
# the default language. The defualt language
# will render to non-suffixed files (e.g index.html).
# All other languages will render with the
# language as a file suffix (e.g index-fr.html,
# index-ja.html). This will be overridable in
# future releases.

language:
  - en
  - ja
  - fr

# Themes are stored in themes/[theme-name]
theme: default

# Site URL
url: https://gitlab.com/samcns/uzu-starter

# Optional parameters (also, comments like this are ok)

# Use a custom dev server port, default is 3000
port: 4040

# Specify a custom project root path
# default is .
project_root: path/to/project/folder

Project folder structure

├── config.yml
├── pages
│   ├── about.mustache
│   └── index.mustache
├── partials
│   ├── footer.mustache
│   ├── head.mustache
│   ├── home.mustache
│   ├── jumbotron.mustache
│   ├── navigation.mustache
│   └── profiles.mustache
├── i18n
│   ├── en.yml
│   ├── fr.yml
│   ├── ja.yml
└── themes
    └── default
        ├── assets
        │   ├── css
        │   ├── favicon.ico
        │   ├── fonts
        │   ├── img
        │   ├── js
        └── layout
            └── layout.mustache

See uzu-starter for a full example.

i18n YAML and Templating

You can separate out the content text to YAML files located in a project-root folder called i18n. Simply create a separate file for each language, like this:

─ i18n
  ├── en.yml
  ├── fr.yml
  ├── ja.yml
  └── ja.yml

An example YAML file might look like this:

---
site_name: The Uzu Project Site
url: https://gitlab.com/samcns/uzu-starter
founders:
  - name: Sam
    title: "Dish Washer"
  - name: Elly
    title: CEO
  - name: Tomo
    title: CFO

# Comments start with a #

# Do not use blank values
this_will_break_thins:
do_this_instead: ""

Template Features

Uzu uses the Template Toolkit templating format for template files.

Features include:

  • GET and SET statements, including implicit versions

    • [% get varname %]
    • [% varname %]
    • [% set varname = value %]
    • [% varname = value %]
  • FOR statement

    • [% for names as name %]
    • [% for names -> name %]
    • [% for name in names %]
    • [% for name = names %]

    If used with Hashes, you'll need to query the .key or .value accessors.

  • IF/ELSIF/ELSE/UNLESS statements.

    • [% if display_links %] -- do this --- [% else %]

      -- do that --

    [% end %]

    • [% unless graphics %]

      -- some html ---

    [% end %]

  • Querying nested data structures using a simple dot operator syntax.

  • CALL and DEFAULT statements.

  • INSERT, INCLUDE and PROCESS statements.

Examples

Single variable

<a class="navbar-brand" href="/">[% site_name %]</a>

For loop

<h1>Company Founders</h1>
<ul>
[% for founder in founders %]
  <li>[% founder.name %], [% founder.title %]</a>
[% end %]
</ul>

IF/ELSEIF/UNLESS

[% if graphics %]
    <img src="[% images %]/logo.gif" align=right width=60 height=40>
[% end %]

Including partials

Partials are stored in the partials directory. You can include these in layouts and pages.

<!doctype html>
<html lang="[% language %]">
[% INCLUDE "head" %]
    <body>
            [% INCLUDE "navigation" %]
            [% content %]
            [% INCLUDE "footer" %]
            </div>
    </body>
</html>

Installation

# Having issues with zef at the moment
zef install Uzu --depsonly
zef install Uzu

Todo

  • Add tests
  • Add build steps to build.pl6
  • Uglify JS / CSS
  • Build deploy process push to S3
  • Features
    • Posts for blogs

Requirements

AUTHORS

CONTRIBUTORS

SEE ALSO