Code Monkey home page Code Monkey logo

luawebgen's Introduction

LuaWebGen

LuaWebGen - static website generator, powered by Lua. Somewhat inspired by Hugo.

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

>> Download latest release <<

Why?

The rant: After using Hugo for a little while I got fed up with how annoying it was to add custom functionality (everything has to be a template), how "content" and "static" files were treated differently, how CSS files were excluded from the templating system, how you couldn't display data from the data folder easily on pages, how confusing index files were, and other silly things.

Being a programmer, I thought treating all files equally and enabling the use of an actual programming language would solve most of these problems.

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 examples folder.

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 website for the full documentation.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.