LuaWebGen

This is the official website for LuaWebGen - the static website generator.

Webpages are generated using HTML and Markdown templates with embedded Lua code. CSS files can also include code.

Example

A blog post, my-first-post.md:

{{
page.title = "The First!"
local foot = "not hand"
}}

Lorem ipsum dolor sit amet, consectetur adipiscing elit.
Duis nec justo mollis, varius nulla sed, commodo nibh.

Foot is {{ foot }}<br>
1 + 2 * 3 = {{ 1+2*3 }}<br>
Current year is {{ os.date"%Y" }}

## List of Cats

{{ for i, cat in ipairs(data.myCats) }}
- Cat {{ i }} is named {{ cat.name }}.
{{ end }}

![Cute cat]({{ getCatImageUrl() }})

Page layout template, page.html:

{{ include"header" }}
{{ include"navigation" }}

<main>
	<h1 id="{{ urlize(page.title) }}">{{ page.title }}</h1>
	{{ page.content }}
</main>

{{ include"footer" }}

See more examples in the repository.

Installation / Usage

There are two versions of LuaWebGen: Windows and universal. Begin by downloading and unzipping the program somewhere.

Windows

Just run webgen.exe, like this:

cd path/to/siteroot
path/to/webgen.exe command [options]

If you add the program folder to your PATH it's a bit nicer:

cd path/to/siteroot
webgen command [options]

Note: The documentation uses this format.

Universal

This version requires these things to be installed:

Some functionality also require these things:

  • Lua-GD - required for image manipulation.
  • LuaSocket - optional, for more CPU-friendly auto-builds.

Hint: On Windows you can simply install Lua for Windows which includes everything that's needed in a neat package.

Run the program like this:

cd path/to/siteroot
lua path/to/webgen.lua command [options]

Note: LuaWebGen has only been tested on Windows so far.

Build Website

To generate a new empty website, run something like this from the command line:

webgen new site "my-website"
cd "my-website"
webgen new page "blog/first-post.md"
webgen build

LuaWebGen uses this folder structure for a website project:

my-website/             -- Root of the website project.
    content/            -- All website content, including pages, images, CSS and JavaScript files.
        index.(html|md) -- Homepage/root index page.
    data/               -- Optional data folder. Can contain Lua, TOML, JSON and XML files.
    layouts/            -- All HTML layout templates.
        page.html       -- Default page layout template.
    output/             -- Where the built website ends up.
    scripts/            -- Optional Lua script folder. Scripts must return a function.
    config.lua          -- Site-wide configurations.

Everything in the content folder will be processed and end up in the output folder.

See the full documentation for more information.