Show HN: Nitro – a Python static site generator

nitro.sh

3 points by sswn 3 days ago

Build static sites in Python instead of a template language. Pages are functions, HTML is Python classes, and the build is a folder you can host anywhere.

No complexity, just code.

Its not 'new', but someone could find it useful.

impoldev 3 days ago

Just curious, how do you rebuild on pages with shared components?

  • sswn 2 days ago

    The renderer will only render the changed component and then the live reload will kick in if you use the nitro dev option. Since a component is just Python, the component will update everywhere its imported.

    If you run nitro build, it will re-compile the whole page (all pages).

imranshah10140 3 days ago

Will I be able to use Tailwind CSS with this?

  • sswn 3 days ago

    Yes, most definitely. I use Tailwind with Nitro on a daily basis.

    Here's how:

    1. Import tailwind 2. Build your components:

    def card(title, body): return Div( Div(title, cls="font-semibold text-zinc-900"), Paragraph(body, cls="mt-1 text-sm text-zinc-600"), cls="rounded-xl border border-zinc-200 bg-white p-6 shadow-sm", )

    3. Run nitro build or nitro dev for live reloads.

    EDIT:

    Here is a full guide: https://nitro.sh/docs/tailwind