I like Astro's free-form approach to building static pages. Is there anything in Python that feels similarly flexible, even if it doesn't replicate the interactive islands part?
Is there a Python alternative to Astro for building flexible static sites?
Answers
For the free-form part, I'd consider Jinja with a small Python build script rather than starting with a full static site generator. You can choose how pages and reusable templates are organized without having to fit everything into a blog structure.
Generate the HTML at build time and add browser-side JavaScript where you need interaction. That won't give you Astro's component ecosystem or islands model, but it gets you a flexible static site.
Reply to this answer
Pelican and Nikola are worth a look if your site is mostly posts. They can generate static sites, but their post-first approach may feel awkward for a collection of custom landing pages. Lektor is another Python option to investigate.
Reply to this answer
Jinja plus htmx is another route if you're open to a backend. Jinja renders HTML, and htmx can request and swap HTML fragments for interactive sections.
That's a different deployment model from a purely static site when the interaction needs fresh data or server-side logic. htmx doesn't turn Python templates into browser-side components.
Reply to this answer
I wouldn't expect a direct equivalent. Astro benefits from the JavaScript UI ecosystem, while Python runs on the server or at build time. You can reproduce a lot of the static generation side, but browser interactivity still needs JavaScript or something like Pyodide or PyScript.
Reply to this answer
Also check out htpy if writing HTML structures in Python sounds appealing. It's not a complete Astro replacement, but it could be an interesting building block alongside a custom static build process.
Reply to this answer
Add your answer
Answers are reviewed before publication.
8n+plendavo_263:
Pelican uses Jinja templates and supports Markdown, so it could be a good fit if the content model matters more than having completely free-form pages.