GenHTML, GenCSS, and GenSSG toolkit
Project description
Gen
Gen is a Python-first toolkit for building static websites.
It is split into two parts:
gen.html: GenHTML, a small object model for creating, editing, parsing, and rendering HTML.gen.ssg: GenSSG, a static site build layer that discovers.ghtmlpage files, runs plugin hooks, builds GenHTML pages, and writes routes todist/.
Status
This is an early implementation. The core GenHTML tree model, parser, GenSSG dispatcher, CLI, and tests are in place.
Install From Source
Create a virtual environment:
python3 -m venv .venv
source .venv/bin/activate
Install dependencies:
python3 -m pip install -r requirements.txt
Install this package locally:
python3 -m pip install -e .
Run tests:
PYTHONPATH=src python3 -m unittest discover -s tests
CLI
Create a new GenSSG project:
gen init --dir my-site
Add a page:
gen add my-site/src/index.ghtml
Build the site:
gen build --dir my-site
Output is written to:
my-site/dist/
GenHTML Example
from gen.html import Div, H1, P, Page, Text
page = Page()
with page:
with Div(class_="content"):
H1("Hello")
P("Built with GenHTML")
print(page.render())
GenSSG .ghtml Contract
A .ghtml file provides page context and build logic:
from gen.html import Element, Page, Text
def CONTEXT(api):
return {
"route": "/",
"title": "Home",
}
def Build(api, context):
page = Page()
with page:
with Element("body"):
with Element("h1"):
Text(context["title"])
return page
CONTEXT(api) may return one dictionary or a list of dictionaries. Each dictionary is passed to Build(api, context).
Build A Distribution
From the repository root:
python3 -m build
This creates source and wheel distributions in:
dist/
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file gen_ssg-0.4.6-py3-none-any.whl.
File metadata
- Download URL: gen_ssg-0.4.6-py3-none-any.whl
- Upload date:
- Size: 32.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
95386cb29197c7889283a5fc30053c714f11f5fe3ddb1a9ad178d50aa335ce2f
|
|
| MD5 |
c3c29ef762245a3ea0affeb10761952c
|
|
| BLAKE2b-256 |
9029bbeafef2f87291a478265405c87f26678b51b722bd58566f421b0efa763b
|