Static website generator without magic.

Code over configuration

Most frameworks for static site generation are declarative. They have little flexibility in terms of how they work, and can require lots of time to setup. Lightweight is meant to be easy to grasp for people who already know Python. It’s core API is handful, but from there you’re free to go in any direction you want.



Get it from PyPI:

pip install lightweight

Code Example

from lightweight import Site, markdown, paths, render, template, feeds, sass

def blog_posts():
    post_template = template('blog-post.html')
    # Use globs to select files.
    return (markdown(path, post_template) for path in paths('posts/**.md'))

site = Site(url='')

# Render a Jinja2 template.
site.add('index.html', jinja('index.html'))

# Render list of Markdown files.
[site.add(f'posts/{post.source_path.stem}.html', post) for post in blog_posts()]

# Render SCSS.
site.add('static/css/style.css', sass('static/scss/lightweight.scss'))

# Include a copy of a directory.

# Execute all included content.

Getting started

Step #1: Install

pip install lightweight

Step #2: Initialize project

lw init example --title Example
cd example

(Optional) Step #2.1: Create venv

python -m venv .venv
source ./.venv/bin/activate
pip install -r requirements.txt

Step #3: Serve at localhost:8080

./ serve

Next steps

Start by looking at module located at project root (it will be similar to code example above) and check out Lightweight docs.