Readit News logoReadit News
Posted by u/_kush 2 years ago
Ask HN: What's the simplest static website generator?
I've tried Jekyll in the past but the setup is a bit overwhelming and it gets complicated super fast. I am looking for something where I can keep my header and footer separate and then include them in every other page. That's it. No CMS and no blog. Is there something which handles this well and is easy to set up?

I use Cloudflare Pages to host my website

VoodooJuJu · 2 years ago
For simply including a common header & footer in pages, any server side include (SSI) compatible server will do: Nginx, Apache, or Caddy.

With SSI, your template for every page would basically look like this:

  <!DOCTYPE html>
  <html lang="en" class="no-js">

  <head>
    <!--#include virtual="/ssi/head.html" -->

    <title></title>
    <meta name="description" content="">
  </head>

  <body>

    <header>
      <!--#include virtual="/ssi/header.html" -->
    </header>

    <main>
    </main>

    <footer>
      <!--#include virtual="/ssi/footer.html" -->
    </footer>

  </body>

  </html>
Making your own SSG is another good solution. They're easy to make, and you can tailor them to your own particular needs.

torstenvl · 2 years ago
gcc -E was my first SSG. Run it on files like this...

    #include "templatestart.html"
    
    <!-- Content -->
    
    #include "tenplateend.html"
Eventually a combination of wanting faster speed and NIH syndrome made me write my own that did significantly less parsing and processing.

Then I built that into a live update system I called TCUP (torstenvl's content update program).

It was a fun project, and ended up being the first non-trivial program I wrote (I was 17-18).

gdorsi · 2 years ago
I suggest you to try out Eleventy (https://www.11ty.dev/)

Quite simple to start, and a nice system to add some scripting and styles without the requirement of bringing in a framework.

_kush · 2 years ago
This is exactly what I was looking for - thanks for the suggestion!
tr3ntg · 2 years ago
11ty user here too, converted from Jekyll. Very pleased with 11ty.
superchris · 2 years ago
Eleventy is pretty great! Highly recommend.
mmusc · 2 years ago
Would be my suggestion to.
hiAndrewQuinn · 2 years ago
Hugo comes out of the box with headers and footers, but you'll probably want to grep around a bit before you understand them fully. I can still recommend my https://github.com/Siilikuin/minimum-viable-hugo as a decent way to get started with a "gears first" approach to Hugo, even though recent developments have made it a bit outdated (in a good way!).
adityaathalye · 2 years ago
Pandoc can be your friend. My site maker [1] is built around it.

I think a hundred or so well-chosen lines of your favourite scripting language can do wonders. Mine is ~300 lines of Bash because I over-engineered a thing or two for kicks. The core of it is maybe 50 lines.

[1] https://github.com/adityaathalye/shite

The README documents the architecture and rationale. Maybe it will help you figure out yours. Happy hacking!

Cerium · 2 years ago
+1 for Pandoc. Something like 100 lines of python extracts tagged documents from my Emacs org docs, converts to html and fixes links.
rcarmo · 2 years ago
Well, I built my static website generator out of Bottle - a single-file HTTP framework that has built-in templating. Bolting on a route that renders Markdown files is pretty simple, really, and a simple os.path.walk() and directly calling the routed function will let you do everything you need.

So you only really need bottle and markdown in your requirements.txt, and around 100ish lines of code. Maybe a little more if you want to upload the results to Cloudflare directly (for which I’d use requests).

You can rinse and repeat that with aiohttp and markdown if you want the async flavor (which is what I’d do these days if I hadn’t already “finished” mine).

And, if you’re into LISP… https://github.com/rcarmo/sushy might make for some fun reading.

kcartlidge · 2 years ago
Bottle is soooo underrated.
rcarmo · 2 years ago
I've built dozens of things on it, some of which (like API servers) were surprisingly load-bearing. Upgrading some of those to aiohttp was trivial (but didn't help much performance-wise, since bottle was already so lightweight).
skilled · 2 years ago
Ugh, this might be an overkill suggestion but Next.js is really easy to work with, and your goal can be accomplished super easily.

Cloudflare page for deploying Next.js static site:

https://developers.cloudflare.com/pages/framework-guides/nex...

On the sidebar they provide a ton of other guides for different generators, too.

_heimdall · 2 years ago
Astro is more simple than NextJS in my opinion, though even that feels like overkill for an SSG that's only needed to keep the header/footer consistent.
yawpitch · 2 years ago
For a use case that straightforward isn’t the simplest SSG going to be:

  cat header.html body.html footer.html > page.html
??