Skip to main content

A tiny Python-authored static site generator for terminal-inspired static web pages.

Project description

PySiteGen

Python-authored static sites.

PySiteGen is a small static site generator for people who would rather compose HTML with Python without any runtime server, client framework, or hidden build graph. PySiteGen gives you primitives. The default visual taste is just a theme layer with terminal-dark aesthetics. It is practical. You write Python functions that return HTML nodes. PySiteGen renders them to static HTML and copies the assets you explicitly ask for. It produces plain files:

public/
  index.html
  assets/
  favicon.png
  robots.txt

Works for docs sites, small product or project pages, personal sites, link hubs, simple SPA-style hash routes, and static pages that benefit from Python data and composition.

Install

python -m pip install pysitegen
pysitegen --version

Start A Site

pysitegen init my-site
cd my-site
pysitegen serve

serve builds once, watches your site files, rebuilds when they change, and reloads the browser tab automatically.

A Page

from pysitegen import a, default_dark, h1, p, page, section

def build():
    return page(
        section(
            p("PySiteGen", class_="eyebrow"),
            h1("Hello from Python."),
            p("This is a static page generated from Python primitives.", class_="muted"),
            a("Read more", href="#more", class_="button primary"),
            class_="container stack",
        ),
        title="Hello",
        description="A PySiteGen page.",
        theme=default_dark(),
    )

Build it and serve it:

pysitegen build
pysitegen serve --host 127.0.0.1 --port 8000

Use pysitegen serve --no-reload when you want the plain static server.

Optional Visual Runtime

PySiteGen can load the !Substrate canvas engine from the CDN for procedural backgrounds. It is not part of the default theme and is only loaded when a page opts in with canvas_background().

from pysitegen import canvas_background, page, visual_canvas, visual_scene

scene = visual_scene(
    "background",
    ("grid", {"spacing": 96}),
    ("nodes", {"count": 24}),
)

page(
    visual_canvas(scene, id="hero-canvas", fps=0, class_="hero-visual"),
    title="Visual",
    behaviors=[canvas_background()],
)

This feature requires the generated page to be online when it loads, because the canvas engine is fetched from the CDN.

This Repo

This repository contains the package source, tests, and the real PySiteGen website:

src/pysitegen/  package source and bundled framework assets
tests/          fixture-based behavior tests
website/        PySiteGen website source

Develop locally:

python -m pip install -e .[dev]
python -m pytest

Build and serve the website:

cd website
pysitegen build
pysitegen serve --host 127.0.0.1 --port 8000

Do not edit website/public/ as source.

Current Limits

PySiteGen is small on purpose.

  • The Markdown parser is intentionally limited.
  • There is no template/layout system yet.
  • There is no plugin system.
  • The default theme is useful, not universal.
  • The API is still young.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pysitegen-1.2.0.tar.gz (30.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pysitegen-1.2.0-py3-none-any.whl (26.9 kB view details)

Uploaded Python 3

File details

Details for the file pysitegen-1.2.0.tar.gz.

File metadata

  • Download URL: pysitegen-1.2.0.tar.gz
  • Upload date:
  • Size: 30.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for pysitegen-1.2.0.tar.gz
Algorithm Hash digest
SHA256 7ea0c0b6b52ffb8fb47baceec7a9ba007b72837d8441532a507fec9e1058704f
MD5 c18d7e8e4c8a7ca13dff62e616f7d549
BLAKE2b-256 b313a095ab8a22df3c65c6d3bc1d852ece5665359cc50d104eb3c7045e38efb3

See more details on using hashes here.

Provenance

The following attestation bundles were made for pysitegen-1.2.0.tar.gz:

Publisher: publish.yml on ujjwalvivek/pysitegen

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pysitegen-1.2.0-py3-none-any.whl.

File metadata

  • Download URL: pysitegen-1.2.0-py3-none-any.whl
  • Upload date:
  • Size: 26.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for pysitegen-1.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e85c1aed1eb3739f24eb65f45756926737515c38fbd2cf57cecf0ae722367e19
MD5 f840880994e7d8163022f5210ee6557e
BLAKE2b-256 8ba580ecd9a2f3dcba442f480a153edcb82f84547bb3a4d7dae2242f21fe0fe2

See more details on using hashes here.

Provenance

The following attestation bundles were made for pysitegen-1.2.0-py3-none-any.whl:

Publisher: publish.yml on ujjwalvivek/pysitegen

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page